ModelItem
This section describes the Creo Object TOOLKIT C++ methods that enable you to access and manipulate ModelItems.
Solid Geometry Traversal
Solid models are made up of 11 distinct types of pfcModelItem, as follows:
•  pfcFeature
•  pfcSurface
•  pfcEdge
•  pfcCurve (datum curve)
•  pfcAxis (datum axis)
•  pfcPoint (datum point)
•  pfcQuilt (datum quilt)
•  pfcLayer
•  pfcNote
•  pfcDimension
•  pfcRefDimension All models inherit from the ModelItemOwner
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 interface pfcModelItemOwner. The method pfcModelItemOwner::ListItems returns a sequence of pfcModelItems contained in the model. You can specify which type of pfcModelItem to collect by passing in one of the enumerated pfcModelItemType objects, or you can collect all pfcModelItems by passing null as the model item type.
If the model has multiple bodies, the method pfcModelItemOwner::ListItems returns the exception pfcXToolkitMultibodyUnsupported.
The methods pfcFeature::ListSubItems and pfcLayer::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 pfcModelItemOwner::GetItemById. This methods enables you to access the model item by identifier.
To access specific model items, call the method pfcModelItemOwner::GetItemByName. This method enables you to access the model item by name.
The method pfcFamColModelItem::GetRefItem returns the dimension or feature used as a header for a family table.
The method pfcSelection::GetSelItem returns the item selected interactively by the user.
The method wfcWSelection::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 pfcModelItems also have a string name that can be changed at any time. The methods pfcModelItem::GetName and pfcModelItem::SetName access this name.
The method wfcWModelItem::GetDefaultName gets the default name assigned to the model item by Creo application at the time of creation.
The method wfcWModelItem::IsNameReadOnly identifies if you can modify the name of the model item.
The method wfcWModelItem::DeleteUserDefinedName deletes the user-defined name of the model item from the Creo database.
The method GetId returns the unique integer identifier for the pfcModelItem.
The pfcModelItem::GetType method returns an enumeration object that indicates the model item type of the specified pfcModelItem. See the section Solid Geometry Traversal for the list of possible model item types.
The method wfcWModelItem::Hide hides the specified model item in the model tree. Use the method wfcWModelItem::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 wfcWModelItem::IsHidden identifies if the specified model item is hidden.
The method wfcWModelItem::IsZoneFeature checks if the specified model item is a zone feature.
The method wfcWView::GetModelItemFromView returns the handle to the model item pfcModelItem for the specified view.
The method wfcViewModelitem::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 pfcBaseSession::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 C++, 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::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:
Superseded Method:
The methods pfcLayer::GetStatus and pfcLayer::SetStatus enables you to access the display status of a layer. The display status is contained in the enumerated type pfcDisplayStatus and the valid values are:
•  pfcLAYER_NORMAL—The selected layer is displayed.
•  pfcLAYER_DISPLAY—The selected layer is displayed.
•  pfcLAYER_BLANK—The selected layer is displayed.
•  pfcLAYER_HIDDEN—The selected layer is displayed.
Use the methods pfcLayer::ListItems, pfcLayer::AddItem, and pfcLayer::RemoveItem to control the contents of a layer.
Note
You cannot add the following items to a layer:
•  pfcITEM_SURFACE,
•  pfcITEM_EDGE,
•  pfcITEM_COORD_SYS,
•  pfcITEM_AXIS,
•  pfcITEM_SIMPREP,
•  pfcITEM_DTL_SYM_DEFINITION,
•  pfcITEM_DTL_OLE_OBJECT,
•  pfcITEM_EXPLODED_STATE.
For these items the method will throw the exception pfcXToolkitInvalidType.
The method pfcLayer::Delete removes the layer (but not the items it contains) from the model.
The method pfcLayer::CountUnsupportedItems returns the number of item types not supported as a pfcModelItem object in the specified layer. This method deprecates the method pfcLayer::HasUnsupportedItems.
Use the method wfcLayerItem::GetLayers to find all the layers containing in a given layer item . This method supports layers in solid models and in drawings.
The method wfcLayerItem::IsLayerItemVisible returns the visibility status for the specified item.
Use the methods wfcLayerItem::RemoveNoUpdate and wfcLayerItem::AddNoUpdate to remove and add a specified item from the layer, respectively, without updating the model tree.
Use the method wfcWModel::ExecuteLayerRules to execute the layer rules on the specified model. The rules must be enabled in the layers to be executed.
The method wfcWModel::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 wfcWModel::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 items on the hidden item layer of the top-level assembly. You can create and save one or more layer states and switch between them to change the display of the assembly.
Methods Introduced:
Use the method wfcLayerState::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::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::DeleteLayerState to delete a specified layer state.
Use the methods wfcLayerState::GetDefaultLayer and wfcLayerState::SetDefaultLayer to set up a default layer with a specified name and type respectively. The method wfcLayerState::SetDefaultLayer requires the default layer type, which is defined in the enumerated type wfcDefLayerType.
The method wfcLayerState::GetLayerData retrieves the reference data for a specified layer state.
The method wfcLayerState::GetLayerStateName retrieves the name of a specified layer state.
Use the method wfcLayerState::HideLayerItem to hide a specific item on the specified layer state.
Use the method wfcLayerState::UnhideLayerItem to remove a specific item from the list of hidden items on a layer state.
Use the method wfcLayerState::IsLayerItemHidden to check if an item is hidden on a layer state.
The method wfcLayerState::RemoveLayer removes a specific layer from a specified layer state.
Use the method wfcLayerStateData::Create to create a new instance of the wfcLayerStateData object. This object contains information about layer state data.
The methods wfcLayerStateData::GetDisplayStatuses and wfcLayerStateData::SetDisplayStatusesget 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 wfcWModel::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 wfcLayerStateData::GetLayerItems and wfcLayerStateData::SetLayerItems get and set the value of the specified layer item.
The methods wfcLayerStateData::GetLayerStateName and wfcLayerStateData::SetLayerStateName get and set the name of the new layer state. The name must only consist of alphanumeric, underscore, and hypen characters.
The methods wfcLayerStateData::GetLayers and wfcLayerStateData::SetLayers get and set the layer state for an array of layers.
The methodwfcWModel::ListLayers returns an array containing the layers in the model.
The method wfcWSolid::ListLayerStates returns an array of layer states in the specified model.
The method wfcWSolid::CreateLayerState creates a new layer state.
The method wfcWSolid::GetActiveLayerState retrieves the active layer state in a specified solid model.
Use the method wfcWModel::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 wfcWSolid::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.