External Objects
This section describes the Creo Object TOOLKIT Java methods that enable you to create and manipulate external objects.
Summary of External Objects
External objects are objects created by an application that is external to Creo Parametric. Although these objects can be displayed and selected within a Creo Parametric session, they can not be independently created by Creo Parametric. Using Creo Object TOOLKIT Java methods, you can define and manipulate external objects, which are then stored in a model database.
Note
External objects are limited to text and wireframe entities. In addition, external objects can be created for parts and assemblies only. That is, external objects can be stored in a part or assembly database only.
In Creo Object TOOLKIT Java application, an external object is defined by a wfcExternalObject object. This DHandle identifies an external object in the Creo Parametric database, which contains the following information for the object:
•  Object class—A class of external objects is a group that contains objects with similar characteristics. All external objects must belong to a class. Object class is contained in the wfcExternalObject.ExternalObjectClass object.
•  Object data—The object data contains information about the display and selection of an external object. Object data is contained in the wfcExternalObject.ExternalObjectData object.
•  Object parameters—External objects can own parameters. You can use the wfcModelItem.WParameter API to get, set, and modify external object parameters.
•  Object references—External objects can reference any Creo object. This functionality is useful when changes to Creo objects need to instigate changes in the external objects. The changes are communicated back to your Creo Object TOOLKIT Java application via the callback methods.
•  Callback methods—Creo Object TOOLKIT Java enables you to specify callback methods for a class of external objects. These methods are called whenever the external object owner or reference is deleted, suppressed, or modified. In this manner, the appearance and behavior of your external objects can depend on the object owner or reference.
External Objects and Object Classes
This section describes the Creo Object TOOLKIT Java methods that relate to the creation and manipulation of external objects and object classes.
Note
This description does not address the display or selection of the external object. For more information see External Object Data.
Creating External Objects
Methods introduced:
After the object class is registered, you can create the external object by calling the method wfcExternalObjectClass.ExternalObjectClass.CreateObject. The input arguments to this method is owner. (Currently, the owner of the external object can be a part or an assembly only.) To get the information of the newly created object, pass the data handle wfcExternalObject.ExternalObject to the method wfcExternalObjectClass.ExternalObjectClass.CreateObject.
When the external object is created, it is assigned an integer identifier that is persistent from session to session. The external object is saved as part of the model database and will be available when the model is retrieved next.
Use the method wfcExternalObjectClass.ExternalObjectClass.GetName to retrieve the name of the external object class.
Use the method wfcExternalObjectClass.ExternalObjectClass.GetType to retrieve the type of the external object class.
External Object Owners
Methods introduced:
The owner of an external object is set during the call to wfcExternalObjectClass.ExternalObjectClass.CreateObject. For example, the “owner” would be the part or assembly where the external object resides.
The method wfcExternalObject.ExternalObject.GetOwner retrieves the owner of an existing external object. To get the owner to an external object, pass the data handle pfcModelItem.ModelItem to the method wfcExternalObject.ExternalObject.GetOwner.
External Object Data
Simply creating an external object does not allow the object to be displayed or selected in Creo Parametric. For this, you must supply external object data that is used, stored, and retrieved by Creo. The data is removed from the model database when the external object is deleted.
External object data is described by the opaque workspace handle wfcExternalObject.ExternalObjectData. The methods required to initialize and modify this object are specific to the type of data being created. That is, creating display data requires one set of methods, whereas creating selection data requires another.
Once you have created a wfcExternalObject.ExternalObjectData object, the manipulation of the external object data is independent of its contents: the methods required to add or remove data are the same for both display and selection data.
Display Data for External Objects
Display data gives information to Creo Parametric about how the external object is to appear in the model window. This data must include the color, scale, line type, and transformation of the external object. In addition, display data can include settings that override the user’s ability to zoom and spin the external object.
Note
Setting the display data does not result in the external object being displayed. To see the object, you must repaint the model window using the method pfcWindow.Window.Repaint.
Methods introduced:
  • wfcExternalObject.ExternalObjectDisplayData_Create
  • Use the method wfcExternalObject.ExternalObjectDisplayData_Create to create a display data information for an external object. The input arguments are as follows:
    •  Ents—Specify the entities in the pfcGeometry.CurveDescriptors object in the specified display data.
    •  EntityColors—Specify the entities in the pfcBase.StdColors object in the specified display data.
    The method wfcExternalObject.ExternalObjectDisplayData_Create returns the display properties of the external object in the wfcExternalObject.ExternalObjectDisplayData object.
    Creating the External Object Entity
    Methods introduced:
    External objects are currently limited to text and wireframe entities. You can specify the entities to be displayed by creating an array of pfcGeometry.CurveDescriptors objects that contain that necessary information. pfcGeometry.CurveDescriptors is a union of specific entity structures, such as line, arrow, arc, circle, spline, and text. Note that when you specify the entities in the pfcGeometry.CurveDescriptors array, the coordinate system used is the default model coordinate system.
    Use the method wfcExternalObject.ExternalObjectDisplayData.GetEntities to retrieve the entities that make up an external object in a specified display data.
    After you have created the array of pfcGeometry.CurveDescriptors objects, you can add entities to the display data by calling the method wfcExternalObject.ExternalObjectDisplayData.SetEntities. The input argument to the method wfcExternalObject.ExternalObjectDisplayData.SetEntities are the entities in the pfcGeometry.CurveDescriptors object.
    Note
    The method wfcExternalObject.ExternalObjectDisplayData.SetEntities supports only wfcENTITY_LINE and wfcENTITY_ARC entities. However, you can draw polygons as multiple lines, and circles as arcs of extent 2 pi.
    The methods wfcExternalObject.ExternalObjectDisplayData.GetEntityColors and wfcExternalObject.ExternalObjectDisplayData.SetEntityColors retrieve and set the display data for a list of entities and the color for each entity. The input argument to the method wfcExternalObject.ExternalObjectDisplayData.SetEntityColors are the list of entities in the pfcBase.StdColors object.
    External Object Display Properties
    Methods introduced:
    By default, when users spin or zoom in on a model, external objects are subjected to the same spin and zoom scale as the model. In addition, by default external objects are always displayed, even if the owner or reference objects are suppressed. Setting external object display properties within display data enables you to change these default behaviors.
    The method wfcExternalObject.ExternalObjectData.GetType retrieves the type of property in specified external object data. To specify which type of property you want to retrieve, pass one of the values in the enumerated type wfcExternalObject.ExternalObjectDataType to this method.
    The methods wfcExternalObject.ExternalObjectDisplayData.GetProperties and wfcExternalObject.ExternalObjectDisplayData.SetProperties retrieve and set the display properties in the specified display data. The input argument to the method wfcExternalObject.ExternalObjectDisplayData.SetProperties are the display properties in the wfcExternalObject.ExternalObjectDisplayDataProperties object.
    External Object Color
    Methods introduced:
    The enumerated type pfcBase.StdColor specifies the colors available for external objects.
    The methods wfcExternalObject.ExternalObjectDisplayData.GetDisplayColor and wfcExternalObject.ExternalObjectDisplayData.SetDisplayColor retrieve and set the object color in the specified display data.
    Line Styles for External Objects
    Methods introduced:
    The enumerated type pfcBase.StdLineStyle specifies the line styles available for specifies the line styles available for external objects.
    The methods wfcExternalObject.ExternalObjectDisplayData.GetLineStyle and v retrieve and set the object line style in the specified display data.
    External Object Scale
    Methods introduced:
    To vary the size of your external object without altering the entities themselves, you must specify an object scale factor as part of the display data.
    The methods wfcExternalObject.ExternalObjectDisplayData.GetScale and wfcExternalObject.ExternalObjectDisplayData.SetScale retrieve and set the scale factor in the specified display data.
    Transformation of the External Object
    Methods introduced:
    You can transform the local coordinates from model coordinates using the three-dimensional transformational matrix.
    The method wfcExternalObject.ExternalObjectDisplayData.GetTransormationMatrix retrieve the transformation matrix contained in a particular set of display data.
    To a perform a coordinate transformation on an external object, use the method wfcExternalObject.ExternalObjectDisplayData.SetTransormationMatrix to set the transformation matrix within the associated display data. The input argument to the method wfcExternalObject.ExternalObjectDisplayData.SetTransormationMatrix is the transformation matrix in the pfcBase.Matrix3D object.
    Selection Data for External Objects
    Methods introduced:
    Use the method wfcExternalObject.ExternalObjectSelectionBoxData_Create to create a selection data information for the specified external object. This method returns the selection data for the external object as a wfcExternalObject.ExternalObjectSelectionBoxData object.
    Selection boxes are specified as part of the external object selection data. These selection boxes indicate locations in which mouse selections will cause the external object to be selected. For the selection to be possible, you must designate a set of “hot spots,” or selection boxes for the object.
    A selection box is defined by the pair of points contained in a wfcExternalObject.SelectionBoxes object. The coordinates of the points are specified in the external object's coordinate system (the default coordinates). The line between the points forms the diagonal of the selection box; the edges of the box lie parallel to the coordinate axes of the external object.
    Note
    PTC recommends that the size and arrangement of the selection boxes be dependent on the size and shape of the external object. If the external object is compact and uniformly distributed in all coordinate directions, one selection box will probably suffice.
    However, if the external object is distributed nonuniformly, or is interfering with other objects, you must designate more specific locations at which selection should occur.
    The method wfcExternalObject.ExternalObjectSelectionBoxData.GetBoxes retrieves the list of selection boxes in a given selection data.
    To set the selection boxes within the selection data, call the method wfcExternalObject.ExternalObjectSelectionBoxData.SetBoxes and pass as input a pointer to a list of wfcExternalObject.SelectionBoxes objects. This enables your external object to have more than one associated selection box.
    Manipulating External Object Data
    Methods introduced:
    The methods in this section enable you to manipulate how the external object data relates to the object itself.
    To add new data to an external object, pass the data handle wfcExternalObject.ExternalObjectData to the method wfcExternalObject.ExternalObject.AddData.
    The method wfcExternalObject.ExternalObject.ModifyData sets the contents of existing object data.
    The method wfcExternalObject.ExternalObject.GetData retrieve the handle for the display or selection data associated with an external object. To specify which type of data you want to retrieve, pass one of the values in the enumerated type wfcExternalObject.ExternalObjectDataType to this method.
    Use the method wfcExternalObject.ExternalObject.RemoveData to remove data from an external object.
    Use the method wfcExternalObject.ExternalObject.GetClass to retrieve the class of an external object.
    External Object References
    You can use external object references to make external objects dependent on model geometry. For example, consider an external object that is modeled as the outward-pointing normal of a surface. Defining the surface as a reference enables the external object to behave appropriately when the surface is modified, deleted, or suppressed.
    In general, an external object can reference any of the geometry that belongs to its owner. In addition, if the owner belongs to an assembly, the external object can also reference the geometry of other assembly components, provided that you supply a valid component path. In general, an external object can reference any of the geometry that belongs to its owner. In addition, if the owner belongs to an assembly, the external object can also reference the geometry of other assembly components, provided that you supply a valid component path.
    Note
    Setting up the references for an external object does not fully define the dependency between the object and the reference. You must also specify the callback method to be called when some action is taken on the reference.
    Creating External Object References
    Methods introduced:
    The method wfcExternalObject.ExternalReferenceInfo_Create creates an external reference information object. The input arguments are as follows:
    •  type—Specify the type of the external reference.
    •  extRefs—Specify the sequence of external feature references.
    You might need to use “reference types” to differentiate among the references of an external object.
    The method wfcExternalObject.ExternalReferenceInfo.GetType retrieve the reference type of the specified reference in an external reference information object. To specify which type of external reference to want to retrieve, pass one of the values in the enumerated type wfcExternalObject.ExternalReferenceType to this method.
    Use the method wfcExternalObject.ExternalReferenceInfo.GetType to set a reference type.
    The method wfcExternalObject.ExternalReferenceInfo.GetExtRefs retrieves the sequence of external feature references in an external reference information object.
    Use the method wfcExternalObject.ExternalReferenceInfo.SetExtRefs to set the external feature reference. The input argument are the external feature references in the wfcExternalObject.WExternalFeatureReferences object.