Creo TOOLKIT implements two data types that enable access to layer information in Creo Parametric:
|
• |
ProLayer—A DHandle that identifies a layer. The ProLayer object is an instance of ProModelitem. |
|
• |
ProLayerItem—A DHandle that identifies a layer item. The valid types of layer item are contained in the enumerated type ProLayerType. |
Functions Introduced:
To get the ProLayer object for a layer with the specified name and owner, call the function ProMdlLayerGet(). You must pass the name of the layer as a wide string.
To visit the layers in a model, use the function ProMdlLayerVisit(). As with other Creo TOOLKIT visit functions, you supply the visit action and visit filter functions.
The function ProMdlLayersCollect() collects a ProArray of layers in the model.
The function ProLayerCreate() creates a new layer with a specified name. It requires as input the ProMdl handle for the model that will own the layer. The function ProLayerDelete() deletes the layer identified by the specified ProLayer object.
The function ProLayerItemsGet() allocates and fills an array of ProLayerItem objects that contains the items assigned to the specified layer.
Note
The function ProLayerItemsGet() is deprecated. For a large number of layer items, the function ProLayerItemsGet() may return an error PRO_TK_OUT_OF_MEMORY to indicate that the function was unable to allocate a ProArray to hold all of the layer items. To address this issue, use the new function ProLayerItemsPopulate().
The function ProLayerItemsPopulate() allocates and fills an array of ProLayerItem objects that contain the type and identifier of the items assigned to the specified layer. This function can retrieve a large
number of items specified on the layer. Use the function ProLayeritemarrayFree() to free the allocated memory.
To initialize a ProLayerItem, call the function ProLayerItemInit(). This function should be used in all cases, except when all of the following are true:
|
• |
The layer owner is a drawing. |
|
• |
The layer item owner is an assembly. |
|
• |
The layer item is a component. |
|
• |
You want to control the display status of this component only in a subassembly with a given path. |
When all of the above conditions are true, use the function ProDwgLayerItemInit() to initialize the ProLayerItem.
The function ProLayerSavedstatusGet() retrieves the saved status for the specified layer. The output argument saved_status is defined by the enumerated data type ProLayerDisplay
To add items to a layer, call the function ProLayerItemAdd(), and pass as input a ProLayer object and the ProLayeritem object for the new layer item. To remove an item from a layer, use the function ProLayerItemRemove() and specify the ProLayeritem object for the item to remove.
The function ProLayerItemAddNoUpdate() adds the specified item to a layer without updating the model tree.
The function ProLayerItemRemoveNoUpdate() removes the specified item from the layer without updating the model tree.
To find all the layers containing a given layer item, use the function ProLayeritemLayersGet(). This function supports layers in solid models and in drawings.
As in an interactive session of Creo Parametric, one of the principal reasons to create a layer is to display or blank its member items selectively. The function ProLayerDisplaystatusGet() obtains the display status of the specified layer, in the form of the ProLayerDisplay enumerated type. The display status can be of following types:
|
• |
PRO_LAYER_TYPE_NONE—The selected layer is displayed. This is the default display status. |
|
• |
PRO_LAYER_TYPE_NORMAL—The layer selected by the user is displayed. |
|
• |
PRO_LAYER_TYPE_DISPLAY—The selected layer is isolated. |
|
• |
PRO_LAYER_TYPE_BLANK—The selected layer is blanked. |
|
• |
PRO_LAYER_TYPE_HIDDEN—The components in the hidden layers are blanked. This status is applicable only in the assembly mode. |
To modify the display status of a layer, call the function ProLayerDisplaystatusSet().
Note
ProLayerDisplaystatusSet() does not repaint the model after it modifies the display status. This is a temporary setting. It will be lost after you save
or retrieve the model. To permanently change the display status, call the function ProLayerDisplaystatusSave(). However, the function ProLayerDisplaystatusSet() updates the model tree for the change in display status of the layer.
The function ProLayerDisplaystatusNoUpdateSet() sets the display status of a layer, without updating the model tree. It returns a boolean value PRO_B_TRUE for the output argument is_update_tree_needed, if the model tree requires an update for change in the display status of a layer. Use the function ProLayerDisplaystatusUpdate() to update the model tree for all the changes in the display statuses of all the layers in the specified model.
Unique functions are required to retrieve and set the status of layers in drawings. ProDwgLayerDisplaystatusGet() takes as input the layer handle and drawing view. The function ProDwgLayerDisplaystatusSet() takes an additional argument as input—the desired display status.
Use the function ProDwgLayerSavedstatusGet() to retrieve the saved status for the specified layer and view.
|
• |
layer —The layer for which you want to retrieve the status . |
|
• |
view —The view of drawing for which you want to retrieve the status. |
The function ProLayerDisplaystatusSave() saves the changes to the display status of all the layers in the specified owner. In addition, the display statuses are saved
in the owner's submodels and drawing views.
To set up a default layer with a specified name, call the function ProLayerDefLayerSet(). This function requires the default layer type, which is defined in the enumerated type ProDefLayerType. To get the name of the default layer with the specified type, call the function ProLayerDefLayerGet().
The function ProLayerViewDependencySet() sets the display of layers of the specified view to depend on the display of layers in the drawing. The syntax of this function
is as follows:
ProLayerViewDependencySet (
ProView view,
ProBoolean depend);
If depend is set to PRO_B_TRUE, the layers in the view will be displayed when the layers in the drawing are displayed. If depend is set to PRO_B_FALSE, the layer display in the view will be independent of the display in the drawing. To determine whether the layer display
in the view is dependent on the display in the drawing, call the function ProLayerViewDependencyGet().
You can define rules in layers. Use the function ProLayerRuleExecute() to execute the layer rules on the specified model. The rules must be enabled in the layers to be executed.
The function
ProLayerRuleCopy() copies the rules from the reference model to the current model for the specified layer. The input arguments are:
|
• |
CurrentModel—Specifies the current model to which the layer rules must be copied. |
|
• |
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. |
|
• |
ReferenceModel—Specifies the reference model from which the layer rules must be copied. |
Use the function ProLayerRuleMatch() 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.
The function
ProLayeritemLayerStatusGet() returns the status of an item for the specified layer. The input arguments are:
|
• |
pro_drawing—Specifies the drawing which is the owner of the layer that contains the specified item. |
|
• |
pro_layer_item—Specifies the layer item. If the owner type of the layer item is PRO_LAYITEM_FROM_PATH, it is mandatory to specify the pro_drawing input argument. |
|
• |
pro_layer—Specifies the layer that contains the item. |
The output argument returns the status of the item using the enumerated data type
ProLayerItemStatus. The valid values are:
|
• |
PRO_LAY_ITEM_STATUS_INCLUDE—Specifies that the status of the layer item is Include. The item is included in the specified layer. |
|
• |
PRO_LAY_ITEM_STATUS_EXCLUDE—Specifies that the status of the layer item is Exclude. The item is excluded in the specified layer. |
|
• |
PRO_LAY_ITEM_STATUS_ADDED_BY_RULE—Specifies that the status of the layer item is defined by rules. |
The enumerated data type
ProLayerItemStatus must have one of the following values:
|
• |
PRO_LAY_ITEM_STATUS_INCLUDE |
|
• |
PRO_LAY_ITEM_STATUS_EXCLUDE |
|
• |
PRO_LAY_ITEM_STATUS_INCLUDE and PRO_LAY_ITEM_STATUS_ADDED_BY_RULE |
|
• |
PRO_LAY_ITEM_STATUS_EXCLUDE and PRO_LAY_ITEM_STATUS_ADDED_BY_RULE |