ModelItem
This section describes the Creo Object TOOLKIT Java methods that enable you to access and manipulate ModelItems.
Solid Geometry Traversal
Solid models are made up of 11 distinct types of ModelItem, as follows:
•  pfcFeature.Feature
•  pfcGeometry.Surface
•  pfcGeometry.Edge
•  pfcGeometry.Curve (datum curve)
•  pfcGeometry.Axis (datum axis)
•  pfcGeometry.Point (datum point)
•  pfcGeometry.Quilt (datum quilt)
•  pfcLayer.Layer
•  pfcNote.Note
•  pfcDimension.Dimension
•  pfcDimension.RefDimension
Each model item is assigned a unique identification number that will never change. In addition, each model item can be assigned a string name. Layers, points, axes, dimensions, and reference dimensions are automatically assigned a name that can be changed.
Getting ModelItem Objects
Methods Introduced:
All models inherit from the interfaceModelItemOwner. The method pfcModelItem.ModelItemOwner.ListItems returns a sequence of ModelItems contained in the model. You can specify which type of ModelItem to collect by passing in one of the enumerated ModelItemType objects, or you can collect all ModelItems by passing null as the model item type.
If the model has multiple bodies, the method pfcModelItem.ModelItemOwner.ListItems returns the exception pfcExceptions.XToolkitMultibodyUnsupported.
Note
The part modeling features introduced in Creo Parametric 1.0 will be excluded from the list of features returned by the method pfcModelItem.ModelItemOwner.ListItems if the model item type is specified asITEM_FEATURE. For example edit round features, flexible modeling features, and so on will be excluded from the list.
The methods pfcFeature.Feature.ListSubItems and pfcLayer.Layer.ListItems produce similar results for specific features and layers. These methods return a list of subitems in the feature or items in the layer.
To access specific model items, call the method pfcModelItem.ModelItemOwner.GetItemById. This methods enables you to access the model item by identifier.
To access specific model items, call the method pfcModelItem.ModelItemOwner.GetItemByName. This methods enables you to access the model item by name.
The method pfcFamily.FamColModelItem.GetRefItem returns the dimension or feature used as a header for a family table.
The method pfcSelect.Selection.GetSelItem returns the item selected interactively by the user.
The method wfcSelect.WSelection.EvaluateAngle measures the angle between two geometry items selected in the selection object wfcWSelection by the user. Both objects must be straight, solid edges.
ModelItem Information
Methods Introduced:
Certain ModelItems also have a string name that can be changed at any time. The methods GetName and SetName access this name.
The method wfcModelItem.WModelItem.GetDefaultName gets the default name assigned to the model item by Creo application at the time of creation.
The method wfcModelItem.WModelItem.IsNameReadOnly identifies if you can modify the name of the model item.
The method wfcModelItem.WModelItem.DeleteUserDefinedName deletes the user-defined name of the model item from the Creo database.
The methodpfcModelItem.ModelItem.GetId returns the unique integer identifier for the ModelItem.
The pfcModelItem.ModelItem.GetType returns an enumeration object that indicates the model item type of the specified ModelItem. See the section Solid Geometry Traversal for the list of possible model item types.
The method wfcModelItem.WModelItem.Hide hides the specified model item in the model tree. Use the method wfcModelItem.WModelItem.Unhide to unhide the model item in the model tree. Using these methods is equivalent to using the commands Hide and Unhide in the Creo user interface.
The method wfcModelItem.WModelItem.IsHidden identifies if the specified model item is hidden.
The method wfcModelItem.WModelItem.IsZoneFeature checks if the specified model item is a zone feature.
The method wfcModelItem.WView.GetModelItemFromView returns the handle to the model item pfcModelItem for the specified view.
The method wfcModelItem.ViewModelitem.GetViewFromModelItem returns the handle to the view pfcView for the specified model item.
Duplicating ModelItems
Methods Introduced:
You can control the creation of ModelItems more than twice for the same Creo item. The method pfcSession.BaseSession.AllowDuplicateModelItems allows you to turn ON or OFF the option to duplicate model items. By default, this option is OFF. To turn the option ON, set the boolean value to FALSE.
Note
If this option is not handled properly on the application side, it can cause memory corruption. Thus, althought you can turn ON and OFF this option as many times as you want, PTC recommends turning ON and OFF this option only once, right after the session is obtained.
Layer Objects
In Creo Object TOOLKIT Java, layers are instances of ModelItem. The following sections describe how to get layer objects and the operations you can perform on them.
Getting Layer Objects
Method Introduced:
The method pfcModel.Model.CreateLayer returns a new layer with the name you specify.
See the section Getting ModelItem Objects for other methods that can return layer objects.
Layer Operations
Methods Introduced:
The methods pfcLayer.Layer.GetStatus and pfcLayer.Layer.SetStatus enables you to access the display status of a layer. The corresponding enumeration class is DisplayStatus and the possible values are Normal, Displayed, Blank, or Hidden.
Use the methods pfcLayer.Layer.ListItems, pfcLayer.Layer.AddItem, and pfcLayer.Layer.RemoveItem to control the contents of a layer.
Note
You cannot add the following items to a layer:
•  ITEM_SURFACE,
•  ITEM_EDGE,
•  ITEM_COORD_SYS,
•  ITEM_AXIS,
•  ITEM_SIMPREP,
•  ITEM_DTL_SYM_DEFINITION,
•  ITEM_DTL_OLE_OBJECT,
•  ITEM_EXPLODED_STATE.
For these items the method will throw the exception pfcExceptions.XToolkitInvalidType.
The method pfcLayer.Layer.Delete removes the layer (but not the items it contains) from the model.
The method pfcLayer.Layer.CountUnsupportedItems returns the number of item types not supported as a pfcModelItem object in the specified layer.
Use the method wfcLayerState.LayerItem.GetLayers to find all the layers containing in a given layer item . This method supports layers in solid models and in drawings.
The method wfcLayerState.LayerItem.IsLayerItemVisible returns the visibility status for the specified item.
Use the methods wfcLayerState.LayerItem.RemoveNoUpdate and wfcLayerState.LayerItem.AddNoUpdate to remove and add a specified item from the layer, respectively, without updating the model tree.
Use the method wfcModel.WModel.ExecuteLayerRules to execute the layer rules on the specified model. The rules must be enabled in the layers to be executed.
The method wfcModel.WModel.CopyLayerRules copies the rules from the reference model to the current model for the specified layer. The input arguments are:
•  LayerName—Specifies the name of an existing layer in both the models. To copy the layer rules, the name of the layer LayerName in both the models must be the same.
•  RefModel— Specifies the reference model from which the layer rules must be copied.
Use the method wfcModel.WModel.MatchLayerRules to compare the rules between the current and reference model for the specified layer. The name of the layer LayerName in both the models must be the same, for comparing the layer rules.
Layer State
A layer state stores the display state of existing layers and all the hidden layers of the top-level assembly. You can create and save one or more layer states and switch between them to change the assembly display.
Methods Introduced:
Use the method wfcLayerState.LayerState.ActivateLayerState to activate the specified layer state. The model of the layer state must be the top model in the active window.
The method wfcLayerState.LayerState.AddLayer adds a new layer to an existing layer state. Specify the new layer and its display state as input arguments to this method.
Use the method wfcLayerState.LayerState.DeleteLayerState to delete a specified layer state.
Use the methods wfcLayerState.LayerState.GetDefaultLayer and wfcLayerState.LayerState.SetDefaultLayer to set up a default layer with a specified name and type respectively. The method wfcLayerState.LayerState.SetDefaultLayer requires the default layer type, which is defined in the enumerated typewfcLayerState.DefLayerType.
The method wfcLayerState.LayerState.GetLayerData retrieves the reference data for a specified layer state.
The method wfcLayerState.LayerState.GetLayerStateName retrieves the name of a specified layer state.
Use the method wfcLayerState.LayerState.HideLayerItem to hide a specific item on the specified layer state.
Use the method wfcLayerState.LayerState.UnhideLayerItem to remove a specific item from the list of hidden items on a layer state.
Use the method wfcLayerState.LayerState.IsLayerItemHidden to check if an item is hidden on a layer state.
The method wfcLayerState.LayerState.RemoveLayer removes a specific layer from a specified layer state.
Use the method wfcLayerState.wfcLayerState.LayerStateData_Create to create a new instance of the wfcLayerState object. This object contains information about layer state data.
The methods wfcLayerState.LayerStateData.GetDisplayStatuses and wfcLayerState.LayerStateData.SetDisplayStatuses get and set, respectively, the display statuses for the layers in the layer state. The number of display statuses is equal to the number of layers present in the layer state.
The method wfcModel.WModel.SaveLayerDisplayStatus saves the changes to the display status of the layers in the specified model and its sub models. For drawings, the display status is saved in the views contained in the drawing.
The methods wfcLayerState.LayerStateData.GetLayerItems and wfcLayerState.LayerStateData.SetLayerItems get and set the value of the specified layer item.
The methods wfcLayerState.LayerStateData.GetLayerStateName and wfcLayerState.LayerStateData.SetLayerStateName get and set the name of the new layer state. The name must only consist of alphanumeric, underscore, and hypen characters.
The methods wfcLayerState.LayerStateData.GetLayers and wfcLayerState.LayerStateData.SetLayers get and set the layer state for an array of layers.
The methodwfcModel.WModel.ListLayers returns an array containing the layers in the model.
The method wfcSolid.WSolid.ListLayerStates returns an array of layer states in the specified model.
The method wfcSolid.WSolid.CreateLayerState creates a new layer state.
The method wfcSolid.WSolid.GetActiveLayerState retrieves the active layer state in a specified solid model.
Use the method wfcModel.WModel.GetLayerItem to initialize a layer item structure. The valid layer item types are defined by the enumerated type wfcLayerType. Do not use this function if the layer item owner is a drawing.
The method wfcSolid.WSolid.UpdateActiveLayerState updates the layer state, which is active in the specified model. If the display statues of layers have changed, then calling this function ensures that the active layer state in the model is updated with the new display statuses of the layers.