Overview of Creo Object TOOLKIT C++
This section provides an overview of Creo Object TOOLKIT C++.
Setting Up Creo Object TOOLKIT C++
Creo Object TOOLKIT C++ is a Creo object-based C++ toolkit API. It can be used with Creo Parametric TOOLKIT inside the same C++ based application.
Installing Creo Object TOOLKIT C++
Creo Object TOOLKIT C++ is a part of the Creo installation, and is installed automatically, if selected.
The following directories are specific to the Creo Object TOOLKIT C++ installation:
•  <creo_otk_loadpoint_app>\include—Contains all the header files specific to Creo Object TOOLKIT C++.
•  <creo_otk_loadpoint_app>\<platform>\obj—Contains platform-specific libraries of Creo Object TOOLKIT C++ which must be used with the Creo Parametric TOOLKIT libraries.
Building a Sample Application
The Creo Object TOOLKIT C++ loadpoint contains sample applications and makefiles. The makefiles show how to build the application on supported platforms.
The sample applications in otk_install.zip demonstrate how to build an application in the Microsoft Visual Studio 2015 environment without using makefiles. otk_install.zip is located in <creo_otk_loadpoint_app>/<machine_type>/obj directory.
Note
From Creo Parametric 4.0 M010 onward, Creo Object TOOLKIT C++ supports Visual Studio 2015. The compiler flags and libraries are available for Visual Studio 2015. Creo Object TOOLKIT C++ no longer supports Visual Studio 2012.
The steps required to build and run the test applications are described in the subsequent sections.
Creo Object TOOLKIT C++ based applications use the same format of creotk.dat file as the Creo Parametric TOOLKIT based applications. Refer to the chapter Creo Object TOOLKIT C++ Registry File, for more information.
The creotk.dat file should contain the following lines:
NAME 			         YourApplicationName
TOOLKIT            OBJECT [optional; omitted means protoolkit]
CREO_TYPE          DIRECT [optional; omitted means PARAMETRIC] 
EXEC_FILE          $LOADDIR/$MACHINE_TYPE/obj/filename.dll
TEXT_DIR           $LOADDIR
STARTUP            dll [dll/spawn/java]
END 
Licensing Options for Creo Object TOOLKIT C++
From Creo Object TOOLKIT C++ 4.0 F000, advanced licensing is supported. To develop and test Creo Object TOOLKIT C++ applications, you require the following licenses:
•  ObjectToolkitCpp—Specifies the basic Creo Object TOOLKIT C++ development license.
•  TOOLKIT-for-3D_Drawings—Specifies the advanced license. Certain methods are available under the 222 license option. Methods that require license 222 have the comment “LICENSE: 222” added in the APIWizard.
From Creo Object TOOLKIT C++ 4.0 F000 onward, the following new libraries have been added. It is mandatory that you include one of the libraries in your application.
•  otk_222.lib—If you have the advanced license option 222, that is, the TOOLKIT-for-3D_Drawings license, include this library in your application.
•  otk_no222.lib—If you do not have the advanced license option, include this library in your application.
Note
From Creo Object TOOLKIT C++ 4.0 F000 onward, all your existing and new applications must include the library otk_222.lib or otk_no222.lib.
To check if you have the Creo Object TOOLKIT C++ license option, run the Ptcstatus utility from the Creo load point. For example, check for the license option ObjectToolkitCpp.
You can check if you have the Creo Object TOOLKIT C++ license option in the Creo user interface. Click File  Help  System Information. In the INFORMATION WINDOW, under Configured Option Modules check for the license option ObjectToolkitCpp. In case the license is not available please contact your system administrator.
The Creo Object TOOLKIT C++ applications must be unlocked before distributing it to the end users. To unlock the application, both the Creo Object TOOLKIT C++ and Creo Parametric TOOLKIT licenses are required.
Unlocking the Creo Object TOOLKIT C++ Application
Before you distribute your application executable to the end user, you must unlock it. This enables the end user to run your applications without having Creo Object TOOLKIT C++ as an option.
To unlock a Creo Object TOOLKIT C++ application, you must have both the Creo Object TOOLKIT C++ license and the Creo Parametric TOOLKIT license.
Note
The Creo Object TOOLKIT C++ license is now a part of the Creo Parametric TOOLKIT license pack. If you are unable to unlock the Creo Object TOOLKIT C++ applications, request for the updated license pack from the Technical Support page.
In Creo 6.0.0.0 and later you can digitally sign your Creo Object TOOLKIT C++ application.
To unlock your application, enter the following command:
     <creo_loadpoint>/<app_name>/bin/protk_unlock.bat [-cxx] [-cxxd] <path
 to executables or DLLs to unlock>
where, <app_name>Parametric for Creo Parametric and Direct for Creo Direct.
Note
•  The Creo Object TOOLKIT C++ is unlocked even if you do not specify the -cxx option.
•  To unlock and digitally sign your application, specify the -cxxd option. Note that it is mandatory to sign your application if you use the -cxxd option. See the section Digitally Signing the Application, for more information on digitally signing your application.
You can provide more than one Creo Parametric TOOLKIT binary file on the command line.
Note
Once you have unlocked the executable, you can distribute your application program to Creo Object TOOLKIT C++ users in accordance with the license agreement.
Using protk_unlock.bat requires a valid Creo Parametric TOOLKIT license to be present and unused on your license server. If the Creo Parametric license server is configured to add a Creo Parametric TOOLKIT license as a startup option, protk_unlock.bat will cause the license server to hold only the Creo Parametric TOOLKIT option for 15 minutes. The license will not be available for any other development activity or unlocking during this period.
If you use -cd option to unlock your application, a message appears asking you to digitally sign your application before using it in Creo.
If the only available Creo Parametric TOOLKIT license is locked to a Creo Parametric license, the entire Creo Parametric license including the Creo Parametric TOOLKIT option will be held for 15 minutes. PTC recommends you configure your Creo Parametric TOOLKIT license option as a startup option to avoid tying up your Creo Parametric licenses.
Note
Only one license will be held for the specified time period, even if multiple applications were successfully unlocked.
Unlocking the application may also require one or more advanced licensing options. Your Creo Object TOOLKIT C++ application may have calls to Creo Object TOOLKIT C++ methods or Creo Parametric TOOLKIT functions, which require one or more advanced licensing options. The protk_unlock application will detect whether any functions using advanced licenses are in use in the application, and if so, will make a check for the availability of the advanced license option. If that option is not present, unlocking will not be permitted. If they are present, the unlock will proceed. Advanced options are not held on the license server for any length of time. Refer to the section Advanced Licensing Options for more information.
If the required licenses are available, the protk_unlock.bat application will unlock the Creo Object TOOLKIT C++ application immediately. An unlocked application does not require any of the Creo Parametric TOOLKIT license options to run. Depending on the functionality invoked by the application, it may still require certain Creo Parametric options to work correctly.
Note
Once an application binary has been unlocked, it should not be modified in any way (which includes statically linking the unlocked binary with other libraries after the unlock). The unlocked binary must not be changed or else Creo Parametric will again consider it "locked".
Digitally Signing the Application
In Creo 6.0.0.0 and later, you can digitally sign your application. Use the standard Microsoft utility SignTool to digitally sign your application. See the Microsoft documentation for more information on this utility and to create the digital certificate.
Unlock Messages
The following table lists the messages that can be returned when you unlock a Creo Object TOOLKIT C++ application.
Message
Cause
<application name>:Successfully unlocked application.
The application is unlocked successfully.
Usage: protk_unlock.bat <one or more Creo Parametric TOOLKIT executables or DLLs>
No arguments supplied.
<application name>:ERROR: No READ access
<application name>:ERROR: No WRITE access
You do not have READ/WRITE access for the executable.
<application name>:Executable is not a Creo Object TOOLKIT C++ application.
The executable is not linked with the Creo Object TOOLKIT C++ libraries, or does not use any methods from those libraries.
<application name>:Executable is already unlocked.
The executable is already unlocked.
Error: Licenses do not contain Creo Parametric TOOLKIT License Code.
A requirement for unlocking a Creo Object TOOLKIT C++ application.
ERROR: No Creo Parametric licenses are available for the startup command specified
Could not contact the license server.
<application name>:Unlocking this application requires option TOOLKIT-for-3D_Drawings.
The application uses methods that require an advanced option; and this option is not available.
The license option 222, that is, the TOOLKIT-for-3D_Drawings license is not available.
How Creo Object TOOLKIT C++ Works
The standard method by which Creo Object TOOLKIT C++ application code is integrated into Creo application is through the use of dynamically linked libraries (DLLs). When you compile your Creo Object TOOLKIT C++ application code and link it with the Creo Object TOOLKIT C++ libraries, you create an object library file designed to be linked into the Creo executable when the Creo application starts up. This method is referred to as DLL mode.
Creo Object TOOLKIT C++ also supports a second method of integration: the “multiprocess,” or spawned mode. In this mode, the Creo Object TOOLKIT C++ application code is compiled and linked to form a separate executable. This executable is designed to be spawned byCreo application and runs as a child process of the Creo session. In DLL mode, the exchanges between the Creo Object TOOLKIT C++ application and Creo application are made through direct function calls. In multiprocess mode, the same effect is created by an inter-process messaging system that simulates direct function calls by passing the information necessary to identify the function and its argument values between the two processes.
Multiprocess mode involves more communications overhead than DLL mode, especially when the Creo Object TOOLKIT C++ application makes frequent calls to Creo Object TOOLKIT C++ library functions, because of the more complex method of implementing those calls. However, it offers the following advantage: it enables you to run the Creo Object TOOLKIT C++ application with a source-code debugger without also loading the whole Creo executable into the debugger.
You can use a Creo Object TOOLKIT C++ application in either DLL mode or multiprocess mode without changing any of the source code in the application. It is also possible to use more than one Creo Object TOOLKIT C++ application within a single session of Creo application, and these can use any combination of modes.
If you use multiprocess mode during development of your application to debug more easily, you should switch to DLL mode when you install the application for your end users because the performance is better in that mode. However, take care to test your application thoroughly in DLL mode before you deliver it. Any programming errors in your application that cause corruption to memory used by the Creo application or Creo Object TOOLKIT C++ are likely to show quite different symptoms in each mode, so new bugs may emerge when you switch to DLL mode.
Although multiprocess mode involves two processes running in parallel, these processes do not provide genuine parallel processing. There is, however, another mode of integrating asz Creo Object TOOLKIT C++ application that provides this ability, called “asynchronous mode”. For more information on asynchronous mode, see the section Asynchronous Mode. The DLL and multiprocess modes are given the general name “synchronous mode”. An asynchronous Creo Object TOOLKIT C++ application is fundamentally different in its architecture from a synchronous mode application, so you should choose between these methods before writing any application code. As a general rule, synchronous mode should be the default choice unless there is some unavoidable reason to use asynchronous mode, because the latter mode is more complex to use.
Note
All Creo Object TOOLKIT C++ calls running in either synchronous (DLL or multiprocess) mode or asynchronous mode always clear the Undo/Redo stack in the Creo session. The Creo user interface reflects this by making the Undo and Redo menu options unavailable.
Domains of Creo Object TOOLKIT C++
Creo Object TOOLKIT C++ consists of the following domains:
•  pfc—This domain provides classes that support basic functionality.
•  wfc—This domain provides classes that support advanced functionality.
•  uifc—This domain provides classes that allow you to create user interface components. Refer to the PTC Creo UI Editor User’s Guide, for more information on how to create and customize the user interface components.
The splitting of classes under pfc and wfc domains is relevant in other bindings, for example Java. However, since Creo Object TOOLKIT is uniform through all its bindings, it is also visible in its C++ binding.
Casting of Creo Object TOOLKIT C++ pfc Classes to wfc Classes
The actual type of pfc objects are specified by the equivalent wfc objects, for example, pfcSolid object is wfcWSolid and pfcFeature object is wfcWFeature. Therefore, the methods from wfcWFeature and wfcWSolid become available to these objects only after applying wfcWFeature::cast or wfcWSolid::cast. You must check that this cast does not return a null pointer.
To make the methods of wfc classes available in pfc classes, cast the pfc objects to the equivalent wfc objects as described in the table below:
Pfc class
Equivalent WFC class
pfcAssembly
wfcWAssembly
pfcComponentPath
wfcWComponentPath
pfcComponentPaths
wfcWComponentPaths
pfcExplodedState
wfcWExplodedState
pfcSimpRep
wfcWSimpRep
pfcSimpReps
wfcWSimpReps
pfcComponentFeat
wfcWComponentFeat
pfcDetailEntityItem
wfcWDetailEntityItem
pfcDetailGroupItem
wfcWDetailGroupItem
pfcDetailNoteItem
wfcWDetailNoteItem
pfcDetailOLEObject
wfcWDetailOLEObject
pfcDetailSymbolDefItem
wfcWDetailSymbolDefItem
pfcDetailSymbolInstItem
wfcWDetailSymbolInstItem
pfcDimension
wfcWDimension
pfcDimension2D
wfcWDimension2D
pfcRefDimension
wfcWRefDimension
pfcUDFDimension
wfcWUDFDimension
pfcDisplay
wfcWDisplay
pfcWindow
wfcWWindow
pfcDrawing
wfcWDrawing
pfcDrawingFormat
wfcWDrawingFormat
pfcFamilyMember
wfcWFamilyMember
pfcFamilyTableRow
wfcWFamilyTableRow
pfcFamilyTableRows
wfcWFamilyTableRows
pfcCoordSysFeat
wfcWCoordSysFeat
pfcCurveFeat
wfcWCurveFeat
pfcDatumAxisFeat
wfcWDatumAxisFeat
pfcDatumPlaneFeat
wfcWDatumPlaneFeat
pfcDatumPointFeat
wfcWDatumPointFeat
pfcFeature
wfcWFeature
pfcFeatures
wfcWFeatures
pfcRoundFeat
wfcWRoundFeat
pfcArc
wfcWArc
pfcArrow
wfcWArrow
pfcAxis
wfcWAxis
pfcBSpline
wfcWBSpline
pfcCircle
wfcWCircle
pfcCompositeCurve
wfcWCompositeCurve
pfcCompositeCurveDescriptor
wfcWCompositeCurveDescriptor
pfcCone
wfcWCone
pfcConeDescriptor
wfcWConeDescriptor
pfcContour
wfcWContour
pfcContours
wfcWContours
pfcCoonsPatch
wfcWCoonsPatch
pfcCoonsPatchDescriptor
wfcWCoonsPatchDescriptor
pfcCurve
wfcWCurve
pfcCurves
wfcWCurves
pfcCylinder
wfcWCylinder
pfcCylinderDescriptor
wfcWCylinderDescriptor
pfcCylindricalSplineSurface
wfcWCylindricalSplineSurface
pfcCylindricalSplineSurfaceDescriptor
wfcWCylindricalSplineSurfaceDescriptor
pfcEdge
wfcWEdge
pfcEdges
wfcWEdges
pfcEllipse
wfcWEllipse
pfcFilletSurface
wfcWFilletSurface
pfcFilletSurfaceDescriptor
wfcWFilletSurfaceDescriptor
pfcForeignSurface
wfcWForeignSurface
pfcForeignSurfaceDescriptor
wfcWForeignSurfaceDescriptor
pfcLine
wfcWLine
pfcNURBSSurface
wfcWNURBSSurface
pfcNURBSSurfaceDescriptor
wfcWNURBSSurfaceDescriptor
pfcPlane
wfcWPlane
pfcPlaneDescriptor
wfcWPlaneDescriptor
pfcPoint
wfcWPoint
pfcPolygon
wfcWPolygon
pfcQuilt
wfcWQuilt
pfcRevolvedSurface
wfcWRevolvedSurface
pfcRevolvedSurfaceDescriptor
wfcWRevolvedSurfaceDescriptor
pfcRuledSurface
wfcWRuledSurface
pfcRuledSurfaceDescriptor
wfcWRuledSurfaceDescriptor
pfcSurface
wfcWSurface
pfcSurfaceDescriptor
wfcWSurfaceDescriptor
pfcSurfaceDescriptors
wfcWSurfaceDescriptors
pfcSurfaces
wfcWSurfaces
pfcText
wfcWText
pfcTorus
wfcWTorus
pfcTorusDescriptor
wfcWTorusDescriptor
pfcDiagram
wfcWDiagram
pfcIntfNeutral
wfcWIntfNeutral
pfcLayout
wfcWLayout
pfcMarkup
wfcWMarkup
pfcModel
wfcWModel
pfcReport
wfcWReport
pfcUnit
wfcWUnit
pfcModelItem
wfcWModelItem
pfcModelItems
wfcWModelItems
pfcParameter
wfcWParameter
pfcParameterOwner
wfcWParameterOwner
pfcRelationOwner
wfcWRelationOwner
pfcNote
wfcWNote
pfcPart
wfcWPart
pfcSelection
wfcWSelection
pfcSelectionOptions
wfcWSelectionOptions
pfcSelections
wfcWSelections
pfcBaseSession
wfcWBaseSession
pfcSession
wfcWSession
pfcSolid
wfcWSolid
pfcRegenInstructions
wfcWRegenInstructions
pfcTable
wfcWTable
pfcXSection
wfcWXSection
Categories of Creo Object TOOLKIT C++ Classes
Creo Object TOOLKIT C++ is made up of a number of classes. Creo Object TOOLKIT C++ supersedes the older PTC object-oriented toolkits without duplicating them. It incorporates Creo Elements/Pro pfc interfaces and adds new interfaces under wfc prefix, where "w" indicates "Writable", because in addition to pfc, the wfc classes provide more capabilities to change a model. For example, you can use the wfc classes to create features from feature element trees.
The following are the main classes:
•  Creo-Related Interfaces—Contains unique methods and attributes that are directly related to the functions in the Creo applications. See the section Creo-Related Interfaces for additional information.
•  Compact Data Classes—Classes containing data needed as arguments to some Creo Object TOOLKIT C++ methods. See the section Compact Data Classes for additional information.
•  Union Classes—Classes with a potential for multiple types of values. See the section Union Classes for additional information.
•  Sequence Classes—Expandable arrays of objects or primitive data types. See the section Sequence Classes for more information.
•  Array Classes—Arrays that are limited to a certain size. See the section Array Classes for more information.
•  Enumeration Classes—Classes that define the enumerated types. See the section Enumeration Classes for more information.
•  ActionListener Classes—Classes that enable you to specify callbacks that will run only if certain events in Creo application take place. See the section Action Listener Classes for more information.
•  Utility Classes—Classes that contain the static methods used to initialize certain Creo Object TOOLKIT C++ objects. See the section Utilities for more information.
Each class shares specific rules regarding initialization, attributes, methods, inheritance, or exceptions. The following sections describe these classes in detail.
List of Classes and Methods
PTC provides a list of all the available classes and methods in Creo Object TOOLKIT C++. The information is available in the file otk_methods.txt located at creo_otk_loadpoint_doc. The file is a tab delimited text file, which can be read in Microsoft Excel.
The file lists all the methods in the pfc and wfc domains along with their description. The file has the following fields:
•  C++ Header, C++ Class, and C++ Method—Lists the Creo Object TOOLKIT C++ header files, classes and methods.
•  Exposure—Specifies PMA if the method is supported in Creo Parametric. The field specifies PMA/DMA when the method is supported in both Creo Parametric and Creo Direct.
•  Description—Describes the class or method.
Creo-Related Interfaces
The Creo-related interfaces contain methods that directly manipulate objects in the Creo application. Examples of these objects include models, features, and parameters.
Initialization, Smart Pointers, and Memory Management
You cannot construct one of these objects using the C++ constructors, because their types are represented by the pure virtual C++ classes. Such objects must be returned by Get or Create method of the special top-level interfaces. The actual type of these objects is represented by a smart pointer. Smart pointer is a class whose instances are kept alive until other objects which refer to them exist in runtime memory . Smart pointers are based on PTC Component Interface Protocol (CIP), and they are defined through the xrchandle template, applied to the pure virtual class whose interface they are about to provide.
For example, pfcSession::GetCurrentModel returns a pfcModel_ptr object set to the current model and pfcParameterOwner::CreateParam returns a newly created pfcParameter_ptr object for manipulation.
Attributes
Attributes within Creo-related objects are not directly accessible, but can be accessed through Get and Set methods. These methods are of the following types:
Attribute name: int XYZ
Methods:    int GetXYZ();
            void SetXYZ (xint i);
Some of the attributes that have been designated as read-only, can be accessed only by the Get method.
Methods
All non-static methods must be used on smart-pointer objects, that follow the C++ syntax for pointers. You must first initialize that object.
For example, the following calls are legal:
pfcSession_ptr session = pfcGetProESession();
pfcWindow_ptr window = session->GetCurrentWindow();
       // You have initialized the window object.
window->Activate();
window->Repaint();
The following calls are illegal:
pfcWindow window; // pfcWindow is a pure virtual class, C++ constructor
cannot be used window.Activate(); Repaint(); // There is no invoking object.
Inheritance
All Creo-related objects are defined as interfaces so that they can inherit methods from other interfaces. To use these methods, call them directly (no casting is needed). For example, for pfcFeature, which inherits pfcModelItem, you can do this:
pfcFeature_ptr myfeature;           // Previously initialized

String name = myfeature->GetName(); // GetName is in the
                                    // class pfcModelItem.
However, if you have a reverse situation, you need to explicitly cast the object. For example:
pfcModelItem_ptr item;  // You know this is a pfcFeature -- perhaps
                        // you previously checked its type.
int number = pfcFeature::cast(item)->GetNumber();
                        // GetNumber() is a pfcFeature method. 
Exceptions
Almost every Creo Object TOOLKIT C++ method can throw an exception of type jxthrowable. Surround each method you use with a xcatchbegin-try-xcatch-xcatchend block to handle any exceptions that are generated. See the Exceptions section for more information.
Compact Data Classes
Compact data classes are data-only classes. They are used, as needed, for arguments and return values for some Creo Object TOOLKIT C++ methods. They do not represent the actual objects in the Creo application.
Initialization
You can create instances of compact classes using the static create methods. For example:
pfcBOMExportInstructions::Create()
Such static methods usually belong to the same class whose instances they create.
Attributes
Attributes within the compact data related classes are not directly accessible, but can be accessed using the Get and Set methods. These methods are of the following types:
Attribute name: int XYZ
Methods:    int GetXYZ();
            void SetXYZ (xint i);
Methods
You must obtain a smart pointer on an object before calling its methods. For example, the following calls are illegal:
pfcSelectionOptions options;

options.SetMaxNumSels(); // The object has not been initialized.
SetOptionsKeywords();    // There is no invoking object
Inheritance
Compact objects can inherit methods from other compact interfaces. To use these methods, call them directly (no casting needed).
Exceptions
Almost every Creo Object TOOLKIT C++ method can throw an exception of type xthrowable. Surround each method you use with a try-catch-finally block to handle any exceptions that are generated.
Union Classes
Unions are interface-like objects. Every union has a discriminator method with the pre-defined name Getdiscr(). This method returns a value identifying the type of data that the union objects holds. For each union member, a pair of Get/Set methods are used to access the different data types. It is illegal to call any Get method except the one that matches the value returned from Getdiscr(). However, any Set method can be called. This switches the discriminator to the new value.
The following is an example of the Creo Object TOOLKIT C++ union:
class pfcParamValue : public xobject
{
xsdeclare (pfcParamValue)
public: 
    pfcParamValueType            Getdiscr ();
    xstring                                  GetStringValue ();
    void                                     SetStringValue (xrstring value);
    xint                                     GetIntValue ();
    void                                     SetIntValue (xint value);
    xbool                                    GetBoolValue ();
    void                                     SetBoolValue (xbool value);
    xreal                                    GetDoubleValue ();
    void                                     SetDoubleValue (xreal value);
    xint 				                 GetNoteId ();
    void                                        SetNoteId (xint value);

private:
    pfcParamvalueValue              mProParamvalue;

public:
        pfcParamValue (const pfcParamvalueValue &inProParamvalue);
        pfcParamValue ();

public:
        const pfcParamvalueValue    &GetProParamvalue();
};
Sequence Classes
Sequences are expandable arrays of primitive data types or objects in Creo Object TOOLKIT C++. All sequence classes have the same methods for adding and accessing the array. Sequence classes are identified by a plural name, or the suffix seq.
Initialization
You cannot construct sequences of objects using the C++ constructors. Static create methods for each sequence type are available. For example, pfcModels::create() returns an empty Models sequence object for you to fill in.
Attributes
The attributes within the sequence objects must be accessed using methods.
Methods
Sequence objects always contain the same methods: get, set, getarraysize, insert, insertseq, removerange, and create. Methods must be invoked from an initialized object of the correct type, except for the static create method, which is invoked from the sequence class.
Inheritance
Sequence classes do not inherit from any other Creo Object TOOLKIT C++ classes. Therefore, you cannot cast sequence objects to any other type of Creo Object TOOLKIT C++ object, including other sequences. For example, if you have a sequence of model items that happen to be features, you cannot make the following call:
pfcFeatures_ptr features = pfcFeatures::cast(modelitems);
To construct the sequence of features, you must insert each member of the sequence separately while casting it to a pfcFeature.
Exceptions
If you try to get or remove an object outside of the range of the sequence, the exceptions cipXInvalidSeqIndex or cipXNegativeIndex are thrown.
Example Code: Sequence Class
The following shows the declaration of the sequence class pfcModels (only public methods are quoted). Please note that the methods of this class come from different typedef, macros and parent classes. There is no specific header file which contains all methods of pfcModels in one place. This is typical for sequences in C++ Creo Object TOOLKIT C++.
// in pfcModel::h:
xclssequence (optional pfcModel_ptr, pfcModels);

// in cipxseq.h:
# define xclssequence(TYPE, NAME)        \
    class NAME : public xtcsequence		 \
 {         \
        xsdeclare (NAME)       \
        NAME () {}           \
        NAME (xint capacity) : xtcsequence<TYPE> (capacity)	    
	  NAME (const NAME *src) : xtcsequence<TYPE> (src)	   \
			static NAME *create ();   \
                	static NAME *createCapacity (xint capacity);     \
}

template <class ElemType>
class xtcsequence : public xtbsequence  <class ElemType>
{
    public:
                xtcsequence ();
                xtcsequence (xint capacity);
                xtcsequence (const xtcsequence<ElemType> *src);
       ~xtcsequence ();
};

template <class ElemType>
class xtbsequence : public xobject, public xbasesequence
{
 public:
     virtual xint				                    getarraysize ();
     inline ElemType                                &operator  [] (xint idx);
     virtual ElemType                                 get (xint idx);
     virtual void       			                            set (xint idx, ElemType value);
     virtual void       			                            append (ElemType value);
     virtual void       			                          operator+= (ElemType value);
     virtual void       			                     insert (xint atidx, ElemType value);
     virtual void                            insertseq (xint atidx,
                                      			       xtbsequence <ElemType> *arr);
	virtual void			                             removerange (xint frominc, xint toexcl);

};
Array Classes
Arrays are groups of primitive types or objects of a specified size. An array can be one or two dimensional. The following array classes are available in pfcBase.h: pfcMatrix3D, pfcPoint2D, pfcPoint3D, pfcOutline2D, pfcOutline3D, pfcUVVector, pfcUVParams, pfcVector2D, and pfcVector3D. See the online reference documentation to determine the exact size of these arrays.
Initialization
You cannot construct one of these objects using the C++ constructors. Static creation methods are available for each array type. For example, the method pfcPoint2D::create returns an pfcPoint2D array object for you to fill in. If the arrays are not initialized, the element values of such arrays must be considered as undefined.
Attributes
The attributes within array objects must be accessed using array class methods.
Methods
Array objects always contain the same methods: get, set, and create. Methods must be invoked from an initialized object of the correct type, except for the create method, which is invoked from the name of the array class.
Inheritance
Array classes do not inherit from any other Creo Object TOOLKIT C++ classes.
Exceptions
If you try to get or remove an object outside of the range of the array, the exceptions cipXInvalidSeqIndex or cipXNegativeIndex are thrown.
Enumeration Classes
In Creo Object TOOLKIT C++ the enumeration classes are used in the same way as an enum is used in C or C++.
Sharing Enumerations and Constants with Creo Parametric TOOLKIT
Since Creo Object TOOLKIT C++ and Creo Parametric TOOLKIT calls can be combined in the same code, there is no need in introducing special enumerations and constants for Creo Object TOOLKIT C++ (except for pfc enumerations and constants which come from pre-Creo Parametric 1.0 pfc interfaces).
Action Listener Classes
Use ActionListeners in Creo Object TOOLKIT C++ to assign programmed reactions to events that occur within te Creo application. Creo Object TOOLKIT C++ defines a set of action listener interfaces that can be implemented enabling Creo to call your Creo Object TOOLKIT C++ application when specific events occur. These interfaces are designed to respond to events from action sources in Creo application. Examples of action sources include the session, user-interface commands, models, solids, parameters, and features.
Initialization
Creo Object TOOLKIT C++ provides a few Action Listener classes, whose actions map most of notification types in Creo Parametric TOOLKITProNotifyType. For example, the actions of pfcSolidActionListener correspond to PRO_SOLID_REGEN_PRE, PRO_SOLID_REGEN_POST, PRO_FEATURE.Create_PRE, PRO_FEATURE.Create_POST, PRO_FEATURE_DELETE_POST, PRO_SOLID_UNIT_CONVERT_PRE, or PRO_SOLID_UNIT_CONVERT_POST. All action listeners are derived from top-level pfcActionListener class. Each Action Listener class contains only pure virtual methods. After choosing an appropriate action listener, you have to subclass it and provide the implementation of all its actions, even if you need only few. To make this more convenient, PTC provides default implementations of each ActionListener class, with an empty implementation of each action. These default classes are not part of Creo Object TOOLKIT C++, but they are skeletons, which you can insert into your application after appropriate modifications. Construct the instance of your Action Listener class using the C++ keyword new. Thereafter, assign your action listener to an pfcActionSource using the AddActionListener() or pfcActionSource::AddActionListenerWithType method of the action source. When you use the method pfcActionSource::AddActionListenerWithType, you can choose to register only specific actions. These actions are specified in the ActionTypes array.
It is recommended to use smart pointer to create an instance of pfc Action Listener class. The smart pointer can be destroyed by calling the pfcActionSource::RemoveActionListener method. The keyword delete is not required to delete the smart pointer.
If an instance of the uifc Action Listener class is assigned to a C-type (*) pointer, then use the C++ keyword delete to delete the pointer. However, if the instance of Action Listener class is assigned to a smart pointer, then the keyword delete is not required to delete the pointer. It is managed and deleted internally.
Attributes
Action listeners do not have any accessible attributes.
Methods
You must override the methods you need in the default class to create an ActionListener object correctly. The methods you create can call other methods in the ActionListener class or in other classes.
Inheritance
All Creo Object TOOLKIT C++ ActionListener objects inherit from the interface pfcActionListener.
Exceptions
Action listeners cause methods to be called outside of your application. Therefore, you must include exception-handling code inside the ActionListener implementation if you want to respond to exceptions. In some methods, when called before an event, propagating an exception out of your method will cancel the impending event.
Example Code: Listener Class
The following example code shows part of the pfcSolidActionListener interface.
class pfcSolidActionListener : public virtual pfcActionListener

{
xaideclare (pfcSolidActionListener)
public:
    virtual void                    OnBeforeRegen (
        pfcSolid_ptr                    Sld,
        optional pfcFeature_ptr         StartFeature
    ) = 0;

    virtual void                    OnAfterRegen (
        pfcSolid_ptr                    Sld,
        optional pfcFeature_ptr         StartFeature,
        xbool                           WasSuccessful
    ) = 0;

    virtual void                    OnBeforeUnitConvert (
        pfcSolid_ptr                    Sld,
        xbool                           ConvertNumbers
    ) = 0;

    virtual void                    OnAfterUnitConvert (
        pfcSolid_ptr                    Sld,
        xbool                           ConvertNumbers
    ) = 0;

    virtual void                    OnBeforeFeatureCreate (
                pfcSolid_ptr            Sld,
                xint                    FeatId
    ) = 0;

    virtual void                    OnAfterFeatureCreate (
                pfcSolid_ptr            Sld,
                pfcFeature_ptr          Feat
    ) = 0;

    virtual void                    OnAfterFeatureDelete (
                pfcSolid_ptr            Sld,
                xint                    FeatId
    ) = 0;
};
Utilities
Each package in Creo Object TOOLKIT C++ has one class that contains special static methods used to create and access some of the other classes in the package. These utility classes have the same name as the package, such as pfcModel::pfcModel.
Initialization
Because the utility packages have only static methods, you do not need to initialize them. Simply access the methods through the name of the class, as follows:
ParamValue pv = pfcModelItem.CreateStringParamValue ("my_param");
Attributes
Utilities do not have any accessible attributes.
Methods
Utilities contain only static methods used for initializing certain Creo Object TOOLKIT C++ objects.
Inheritance
Utilities do not inherit from any other Creo Object TOOLKIT C++ classes.
Exceptions
Methods in utilities can throw jxthrowable type exceptions.
Sample Utility Class
The following code example shows the utility class pfcGlobal.

public class pfcGlobal
{
public static pfcSession::Session GetProESession()
    throws jxthrowable

public static stringseq GetProEArguments()
    throws jxthrowable

public static string GetProEVersion()
    throws jxthrowable

public static string GetProEBuildCode()
    throws jxthrowable
}
Creo Object TOOLKIT C++ Support for Creo
Methods Introduced:
Creo Object TOOLKIT C++ supports applications in synchronous and asynchronous modes for Creo applications. It also supports Creo Direct in certain functional areas.
Note
Creo Object TOOLKIT C++ does not support other Creo applications, such as, Creo Layout, Creo Simulate and so on.
In future, the methods of Creo Object TOOLKIT C++ will be enhanced to extend support to all Creo applications.
To check which methods from pfc and wfc domains are supported for Creo Direct, refer to the Creo Object TOOLKIT C++ APIWizard. The methods that are supported for Creo Direct have the comment “This method is enabled for Creo Direct” in the APIWizard. All the methods or a subset of methods in the following areas is supported for Creo Direct:
•  Model, Part, Assembly
•  Solid
•  File Operations
•  Selection
•  Geometry
•  Window
•  PDM Interaction
•  External Data
Creo Direct supports all the methods in the uifc domain.
If you call a method that is not supported in the Creo application, the pfcXMethodForbidden exception is thrown.
You can also develop the Creo Direct applications in Creo Parametric environment. You can simulate the Creo type at runtime and check for pfcXMethodForbidden exceptions.
Use the method wfcWSession::RunAsCreoType to run the Creo Object TOOLKIT C++ application in the specified Creo application. Specify the Creo application using the enumerated data type wfcCreoType. The valid values are:
•  wfcCREO_PARAMETRIC
•  wfcCREO_DIRECT
Note
The method wfcWSession::RunAsCreoType must be used only with Creo Parametric. If used with other Creo applications, the method returns the pfcXMethodForbidden exception. Therefore, you must remove the call to this method before deploying the final application.
The method wfcWSession::GetCreoType returns the Creo application to which the Creo Object TOOLKIT C++ application is connected.
The keywords toolkit and creo_type defined in the registry file are used to specify the information required to run a Creo Object TOOLKIT C++ application in a non-Creo Parametric application. The non-Creo Parametric applications read the information from the registry file.
For example, the standard form of the registry file in executable mode for Creo Direct is as follows:
name           YourApplicationName
exec_file      $LOADDIR/$MACHINE_TYPE/obj/filename.exe
text_dir        $LOADDIR
toolkit          object
creo_type    direct
end
The keyword toolkit has two values:
•  protoolkit for applications based on Creo Parametric TOOLKIT
•  object for applications based on Creo Object TOOLKIT C++
If you run an application of type protoolkit with any Creo application other than Creo Parametric, an error message appears. Similarly, if you try to run the Creo Object TOOLKIT C++ application on a Creo application other than the one mentioned in the registry file, an error message appears.
The Auxiliary Applications dialog box is available within the non-Creo Parametric applications.
Support for Multi-CAD Models Using Creo Unite
Creo Unite enables you to open non-Creo parts and assemblies in Creo Parametric and other Creo applications such as Creo Simulate and Creo Direct without creating separate Creo models. You can then assemble the part and assembly models that you opened as components of Creo assemblies to create multi-CAD assemblies of mixed content.
You can open the part and assembly models of the following non-Creo file formats in Creo applications:
•  CATIA V5 (.CATPart, .CATProduct)
•  CATIA V5 CGR
•  CATIA V4 (.Model)
•  SolidWorks (.sldasm, .sldprt)
•  NX (.prt)
Most of the Creo Object TOOLKIT C++ methods support multi-CAD assemblies. The methods which do not support assemblies of mixed content throw the exception pfcXToolkitUnsupported, when a non-native part or assembly is passed as the input model.
Using Creo Object TOOLKIT C++ with Creo Parametric TOOLKIT
Since C++ and C functions can be used together in the same application, you can use the Creo Parametric TOOLKIT applications where the Creo Object TOOLKIT C++ interfaces are not yet available. To do this seamlessly, the program should be able to obtain Creo Parametric TOOLKIT handles out of Creo Object TOOLKIT C++ objects and vice versa. For example, to obtain a ProMdl out of pfcModel_ptr and pfcModel_ptr out of ProMdl.
Two static functions allow you to achieve this:
•  xobject_ptr wfcGetObjectFromHandle (wfcHandleType type, void *handle);
•  const void *wfcGetHandleFromObject (pfcObject_ptr object);
The static function wfcGetObjectFromHandle returns a Creo Object TOOLKIT C++ object from a Creo Parametric TOOLKIT handle. Use the function wfcGetHandleFromObject to obtain a Creo Parametric TOOLKIT handle from a Creo Object TOOLKIT C++ object.
Note
The calls to Creo Parametric TOOLKIT functions from a Creo Object TOOLKIT C++ based application is supported only for Creo Parametric. Thus, the support for functions wfcGetHandleFromObject and wfcGetObjectFromHandle is restricted to applications that run with Creo Parametric only.
For more information on all the possible values of wfcHandleType see wfcGlobal.h. The following is an example of using wfcGetObjectFromHandle and wfcGetHandleFromObject:
// getting pfcFeature_ptr out of ProFeature
ProFeature *feat;
pfcFeature_ptr pfcFeat = pfcFeature::cast
( wfcGetObjectFromHandle(wfcProModelitemHandle, (void*)feat) ); // getting ProFeature out of pfcFeature_ptr pfcFeature_ptr pfcFeat; ProFeature *feat = (ProFeature*) wfcGetHandleFromObject
( pfcObject::cast(pfcFeat) );
Migrating Creo Parametric TOOLKIT Applications to Creo Object TOOLKIT C++ Using Tools
The tool mark_otkmethod.pl helps you migrate Creo Parametric TOOLKIT applications to Creo Object TOOLKIT C++. This perl script is located at <creo_loadpoint>\<datecode>\Common Files\protoolkit\scripts. The script searches for Creo Parametric TOOLKIT functions, and recommends possible replacing Creo Object TOOLKIT C++ methods.
The Creo Parametric TOOLKIT APIWizard also provides links to equivalent Creo Object TOOLKIT C++ methods.
Creating Applications
The following sections describe how to create applications. The topics are as follows:
Application Hierarchy
The rules of object dependencies require a certain sequence of object creation when you start a Creo Object TOOLKIT C++ application. First, you must obtain a wfcSessionm :
wfcWSession_ptr ses = wfcWSession::cast(pfcGetProESession()
which returns a handle to the current session of Creo application.
The application must iterate down to the level of object you want to access. For example, to list all the datum axes contained in the hole features in all models in session, do the following:
1. Get a handle to the session.
2. Get the models that are active in the session.
3. Get the feature model items in each model.
4. Filter out the features of type hole.
5. Get the subitems in each feature that are axes.
Exception Handling
Many Creo Object TOOLKIT C++ methods can throw an exception. Exceptions match errors returned by Creo Parametric TOOLKIT APIs. The following sections describe the exceptions in detail.
Note
Exceptions thrown by Creo Object TOOLKIT C++ methods are not documented in the Creo Object TOOLKIT C++ User's Guide. Refer to the APIWizard for more information on method specific exceptions.
Cip Exceptions
The Cip exceptions are thrown by Cip classes. For more information, cipxx.h and its includes. With the exception of intseq, realseq, boolseq, and stringseq classes, these classes are used only internally.
The following table describes these exceptions.
Exception
Purpose
cipXInvalidArrayIndex, cipXInvalidDictIndex, cipXNegativeIndex
Illegal index value used when accessing a Cip array, sequence, or dictionary. (The Creo Object TOOLKIT C++ interface does not currently include any dictionary classes.)
Other, internal errors
Internal assertions that should not append and which need not be caught individually.
PFC/WFC Exceptions
The PFC/WFC exceptions are thrown by the classes that make up Creo Object TOOLKIT C++’s public interface. The following table describes these exceptions.
Exception
Purpose
pfcXBadExternalData
Indicates an attempt to read contents of an external data object which has been terminated.
pfcXBadGetArgValue
Indicates an attempt to read the wrong type of data from the ArgValue union.
pfcXBadGetExternalData
Indicates an attempt to read the wrong type of data from the ExternalData union.
pfcXBadGetParamValue
Indicates an attempt to read the wrong type of data from the ParamValue union.
pfcXBadOutlineExcludeType
Indicates that an invalid type of item was passed to the outline calculation method.
pfcXCancelProEAction
This exception type will not be thrown by Creo Object TOOLKIT C++ methods, but you may instantiate and throw this from certain ActionListener methods to cancel the corresponding action in the Creo application.
pfcXCannotAccess
Indicates that the contents of a Creo Object TOOLKIT C++ object cannot be accessed in this situation.
pfcXEmptyString
Indicates an empty string was passed to a method that does not accept this type of input.
pfcXInvalidEnumValue
Indicates an invalid value for a specified enumeration class.
pfcXInvalidFileName
Indicates that a file name passed to a method was incorrectly structured.
pfcXInvalidFileType
Indicates a model descriptor contained an invalid file type for a requested operation.
pfcXInvalidModelItem
Indicates that the item requested to be used is no longer usable (for example, it may have been deleted).
pfcXInvalidSelection
Indicates that the selection passed is invalid or is missing a needed piece of information. For example, its component path, drawing view, or parameters.
pfcXModelNotInSession
Indicates that the model is no longer in session; it may have been erased or deleted.
pfcXNegativeNumber
Numeric argument was negative.
pfcXNumberTooLarge
Numeric argument was too large.
pfcXProEWasNotConnected
The Creo session is not available so the operation failed.
pfcXSequenceTooLong
Indicates that the sequence argument was too long.
pfcXStringTooLong
Indicates that the string argument was too long.
pfcXUnimplemented
Indicates unimplemented method.
pfcXUnknownModelExtension
Indicates that a file extension does not match a known Creo model type.
Creo Parametric TOOLKIT Errors
The pfcXToolkitError exception provides access to error codes from Creo Parametric TOOLKIT functions that Creo Object TOOLKIT C++ uses internally and to the names of the functions returning such errors. pfcXToolkitError is the exception you are most likely to encounter because Creo Object TOOLKIT C++ is built on top of Creo Parametric TOOLKIT. The following table lists the integer values that can be returned by the pfcXToolkitError::GetErrorCode() method and shows the corresponding Creo Parametric TOOLKIT constant that indicates the cause of the error. Each specific pfcXToolkitError exception is represented by an appropriately named child class, allowing you to catch specific exceptions you need to handle separately.
pfcXToolkitError Child Class
Creo Parametric TOOLKIT Error
#
pfcXToolkitGeneralError
PRO_TK_GENERAL_ERROR
-1
pfcXToolkitBadInputs
PRO_TK_BAD_INPUTS
-2
pfcXToolkitUserAbort
PRO_TK_USER_ABORT
-3
pfcXToolkitNotFound
PRO_TK_E_NOT_FOUND
-4
pfcXToolkitFound
PRO_TK_E_FOUND
-5
pfcXToolkitLineTooLong
PRO_TK_LINE_TOO_LONG
-6
pfcXToolkitContinue
PRO_TK_CONTINUE
-7
pfcXToolkitBadContext
PRO_TK_BAD_CONTEXT
-8
pfcXToolkitNotImplemented
PRO_TK_NOT_IMPLEMENTED
-9
pfcXToolkitOutOfMemory
PRO_TK_OUT_OF_MEMORY
-10
pfcXToolkitCommError
PRO_TK_COMM_ERROR
-11
pfcXToolkitNoChange
PRO_TK_NO_CHANGE
-12
pfcXToolkitSuppressedParents
PRO_TK_SUPP_PARENTS
-13
pfcXToolkitPickAbove
PRO_TK_PICK_ABOVE
-14
pfcXToolkitInvalidDir
PRO_TK_INVALID_DIR
-15
pfcXToolkitInvalidFile
PRO_TK_INVALID_FILE
-16
pfcXToolkitCantWrite
PRO_TK_CANT_WRITE
-17
pfcXToolkitInvalidType
PRO_TK_INVALID_TYPE
-18
pfcXToolkitInvalidPtr
PRO_TK_INVALID_PTR
-19
pfcXToolkitUnavailableSection
PRO_TK_UNAV_SEC
-20
pfcXToolkitInvalidMatrix
PRO_TK_INVALID_MATRIX
-21
pfcXToolkitInvalidName
PRO_TK_INVALID_NAME
-22
pfcXToolkitNotExist
PRO_TK_NOT_EXIST
-23
pfcXToolkitCantOpen
PRO_TK_CANT_OPEN
-24
pfcXToolkitAbort
PRO_TK_ABORT
-25
pfcXToolkitNotValid
PRO_TK_NOT_VALID
-26
pfcXToolkitInvalidItem
PRO_TK_INVALID_ITEM
-27
pfcXToolkitMsgNotFound
PRO_TK_MSG_NOT_FOUND
-28
pfcXToolkitMsgNoTrans
PRO_TK_MSG_NO_TRANS
-29
pfcXToolkitMsgFmtError
PRO_TK_MSG_FMT_ERROR
-30
pfcXToolkitMsgUserQuit
PRO_TK_MSG_USER_QUIT
-31
pfcXToolkitMsgTooLong
PRO_TK_MSG_TOO_LONG
-32
pfcXToolkitCantAccess
PRO_TK_CANT_ACCESS
-33
pfcXToolkitObsoleteFunc
PRO_TK_OBSOLETE_FUNC
-34
pfcXToolkitNoCoordSystem
PRO_TK_NO_COORD_SYSTEM
-35
pfcXToolkitAmbiguous
PRO_TK_E_AMBIGUOUS
-36
pfcXToolkitDeadLock
PRO_TK_E_DEADLOCK
-37
pfcXToolkitBusy
PRO_TK_E_BUSY
-38
pfcXToolkitInUse
PRO_TK_E_IN_USE
-39
pfcXToolkitNoLicense
PRO_TK_NO_LICENSE
-40
pfcXToolkitBsplUnsuitableDegree
PRO_TK_BSPL_UNSUITABLE_DEGREE
-41
pfcXToolkitBsplNonStdEndKnots
PRO_TK_BSPL_NON_STD_END_KNOTS
-42
pfcXToolkitBsplMultiInnerKnots
PRO_TK_BSPL_MULTI_INNER_KNOTS
-43
pfcXToolkitBadSrfCrv
PRO_TK_BAD_SRF_CRV
-44
pfcXToolkitEmpty
PRO_TK_EMPTY
-45
pfcXToolkitBadDimAttach
PRO_TK_BAD_DIM_ATTACH
-46
pfcXToolkitNotDisplayed
PRO_TK_NOT_DISPLAYED
-47
pfcXToolkitCantModify
PRO_TK_CANT_MODIFY
-48
pfcXToolkitCheckoutConflict
PRO_TK_CHECKOUT_CONFLICT
-49
pfcXToolkitCreateViewBadSheet
PRO_TK_CRE_VIEW_BAD_SHEET
-50
pfcXToolkitCreateViewBadModel
PRO_TK_CRE_VIEW_BAD_MODEL
-51
pfcXToolkitCreateViewBadParent
PRO_TK_CRE_VIEW_BAD_PARENT
-52
pfcXToolkitCreateViewBadType
PRO_TK_CRE_VIEW_BAD_TYPE
-53
pfcXToolkitCreateViewBadExplode
PRO_TK_CRE_VIEW_BAD_EXPLODE
-54
pfcXToolkitUnattachedFeats
PRO_TK_UNATTACHED_FEATS
-55
pfcXToolkitRegenerateAgain
PRO_TK_REGEN_AGAIN
-56
pfcXToolkitDrawingCreateErrors
PRO_TK_DWGCREATE_ERRORS
-57
pfcXToolkitUnsupported
PRO_TK_UNSUPPORTED
-58
pfcXToolkitNoPermission
PRO_TK_NO_PERMISSION
-59
pfcXToolkitAuthenticationFailure
PRO_TK_AUTHENTICATION_FAILURE
-60
pfcXToolkitAppNoLicense
PRO_TK_APP_NO_LICENSE
-92
pfcXToolkitAppExcessCallbacks
PRO_TK_APP_XS_CALLBACKS
-93
pfcXToolkitAppStartupFailed
PRO_TK_APP_STARTUP_FAIL
-94
pfcXToolkitAppInitialization
Failed
PRO_TK_APP_INIT_FAIL
-95
pfcXToolkitAppVersionMismatch
PRO_TK_APP_VERSION_MISMATCH
-96
pfcXToolkitAppCommunication
Failure
PRO_TK_APP_COMM_FAILURE
-97
pfcXToolkitAppNewVersion
PRO_TK_APP_NEW_VERSION
-98
The exception XProdevError represents a general error that occurred when executing a Pro/DEVELOP function and is equivalent to a Xtoolkit general error. (PTC does not recommend the use of Pro/DEVELOP functions.)
The exception XExternalDataError and its children are thrown from External Data methods. See the chapter on External Data for more information.
Approaches to Creo Object TOOLKIT C++ Exception Handling
To deal with the exceptions generated by Creo Object TOOLKIT C++ methods surround each method with a try-xcatchbegin-xcatch-xcatchend block. For example:
try {
    OtkObject->DoSomething()
}
xcatchbegin
xcatch (xthrowable, x) {
    // Respond to the exception.
}
xcatchend
Rather than catching the generic exception, you can set up your code to respond to specific exception types, using multiple catch blocks to respond to different situations, as follows:
try
{
    OtkObject->DoSomething()
}
xcatchbegin
xcatch (pfcXToolkitError, x)
    {
        // Respond based on the error code.
        x->GetErrorCode();
    }
xcatch (cipXConnectionClosed, x) 
    {
        // Respond to the exception.
    }
catch (xthrowable, x)  // Do not forget to check for
                        // an unexpected error!
{
        // Respond to the exception.
}
xcatchend
catch(...) {
        // non-OTK exceptions go here
}
Version Compatibility: Creo Parametric and Creo Object TOOLKIT C++
In many situations it will be inconvenient or impossible to ensure that the users of your Creo Object TOOLKIT C++ application use the same build of Creo Parametric used to compile and link the Creo Object TOOLKIT C++ application. This section summarizes the rules for mixing Creo Object TOOLKIT C++ and Creo Parametric versions. The Creo Object TOOLKIT C++ version is the Creo Parametric CD version from which the user installed the Creo Object TOOLKIT C++ version used to compile and link the application.
Method Introduced:
This method returns the version number of the Creo Parametric executable to which the Creo Object TOOLKIT C++ application is connected. This number is an absolute number and represents the major release of the product. The version number of Creo Parametric 3.0 is 32.
The following points summarize the rules for mixing Creo Object TOOLKIT C++ and Creo Parametric versions:
•  Creo Parametric release newer than a Creo Object TOOLKIT C++ release:
This works in many, but not all, cases. The communication method used to link Creo Object TOOLKIT C++ to Creo Parametric provides full compatibility between releases. However, there are occasional cases where changes internal to Creo Parametric may require changes to the source code of a Creo Object TOOLKIT C++ application in order that it continues to work correctly. Whether you need to convert Creo Object TOOLKIT C++ applications depends on what functionality it uses and what functionality changed in Creo Parametric and Creo Object TOOLKIT C++. PTC makes every effort to keep these effects to a minimum. The Release Notes for Creo Object TOOLKIT C++ detail any conversion work that could be necessary for that release.
•  Creo Parametric build newer than Creo Object TOOLKIT C++ build
This is always supported.
Retrieving Creo Datecode
Method Introduced:
The method wfcWSession::GetDisplayDateCode returns the user-visible datecode string from the Creo application. The applications that present a datecode string to users in messages and information should use the Creo datecode format.
Compatibility of Deprecated Methods
In a release cycle, some methods are deprecated, and new methods are added. The deprecated methods are supported in the current release, and then obsoleted in a future release. You can either choose to let the deprecated methods work in the current release, or allow only new methods to work. Use the methods explained in this section along with the compatibility value to work with either deprecated or new methods for the current release.
Methods Introduced:
The methods pfcAppInfo::GetCompatibility and pfcAppInfo::SetCompatibility get and set the compatibility value for the specified application using the enumerated data type pfcCreoCompatibility. The valid values are:
•  pfcCompatibilityUndefined—Specifies that compatibility value is not set. The default compatibility value is used.
•  pfcC3Compatible—Specifies that the methods deprecated in Creo Object TOOLKIT C++ 4.0 are compatible and continue working in Creo Object TOOLKIT C++ 4.0. By default the compatibility is set to pfcC3Compatible.
•  pfcC4Compatible—Specifies that the methods deprecated in Creo Object TOOLKIT C++ 4.0 will not work in Creo Object TOOLKIT C++ 4.0. If your application uses the deprecated methods, you must replace these methods with new methods and rebuild you applications.
Note
If you rebuild or run Creo Object TOOLKIT C++ applications from previous releases in the current release, the compatibility is set pfcC3Compatible to current release. For example, if you rebuild a Creo Object TOOLKIT C++ 3.0 application in release 4.0, the compatibility is set to pfcC3Compatible. To set the compatibility to the current release, use the method pfcAppInfo::SetCompatibility.
The method pfcAppInfo::Create creates a new instance of the pfcAppInfo object.
The methods pfcSession::GetAppInfo and pfcSession::SetAppInfo get and set the information for an application in terms of their compatibility value as a pfcAppInfo object.
Visit Methods
Methods Introduced:
In a Creo Object TOOLKIT C++ application, you may often want to perform an operation on all the objects that belong to another object, such as all the features in a part, or all the surfaces in a feature. For such cases, Creo Object TOOLKIT C++ provides an appropriate visit method. The visit method is an alternative to passing back an array of data.
The method wfcWAssembly::VisitComponents visits all the components in an assembly. The input argument visitingClient specifies an object of type wfcVisitingClient that contains the visit action and filter methods for visiting items.
The method wfcVisitingClient::ApplyAction is the method that you want to be called for each item and pass its pointer to the Creo Object TOOLKIT C++ visit method. This method is referred to as the visit action method. The Creo Object TOOLKIT C++ visit method calls the visit action method once for every visited item.
The method wfcVisitingClient::ApplyFilter is referred to as the filter method. The filter method is called for each visited item before the action method. The return value of the filter method controls whether the action method must be called for that item. You can use the filter method as a way of visiting only a particular subset of the items in the list.
The filter method must return one of the following values defined in enumerated data type wfcStatus:
•  wfcTK_CONTINUE—Specifies that the visit action method must not visit this object, but continue to visit the subsequent objects.
•  Any other value—Specifies that the visit action method must be called for this object. The return value must be passed as the input argument to the visit action method.
The visit action method must return one of the following values defined in enumerated data type wfcStatus:
•  wfcTK_NO_ERROR—Specifies that the visit action method must continue visiting the other objects in the list.
•  wfcTK_E_NOT_FOUND—Specifies that no items of the specified type were found and therefore no objects could be visited.
•  Any other value including wfcTK_CONTINUE—Terminates the visit. Typically this status is returned from the visit action method on termination, so that the calling method knows the reason for the abnormal termination of the visit.
For the method wfcWSolid::VisitItems, the actual type of item passed to the methods wfcVisitingClient::ApplyAction and wfcVisitingClient::ApplyFilter is of type wfcWModelItem. To make the methods of wfcWModelItem available in pfcModelItem, cast pfcModelItem to wfcWModelItem.
Similarly, for the method wfcWAssembly::VisitComponents, to make the methods of wfcWComponentFeat available in pfcObject, cast pfcObject to wfcWComponentFeat.
If you are using Creo Object TOOLKIT C++ together with Creo Parametric TOOLKIT, use the utility method wfcStatusFromPro to convert the ProError to equivalent Creo Object TOOLKIT C++ wfcStatus. Use the utility method wfcStatusToPro to convert a Creo Object TOOLKIT C++ wfcStatus to an equivalent ProError.
The method wfcWFeatureGroup::VisitDimensions traverses the members of the feature group.
The method wfcWModel::VisitItems visits the pfcModelItemType objects in the model for the specified type of item.
The method wfcWFeature::VisitItems visits the annotation elements in the specified feature.
The method wfcWModel::VisitDetailItems visits the pfcDetailType objects in the model for the specified drawing and sheet of a detail item.