Features
All Creo Parametric solid models are made up of features. This section describes how to program on the feature level using Creo.JS.
Access to Features
Methods and Properties Introduced:
  • pfcFeature.ListChildren()
  • pfcFeature.ListParents()
  • pfcFeature.GroupDirectHeader
  • pfcFeatureGroup.GroupLeader
  • pfcFeaturePattern.PatternLeader()
  • pfcFeaturePattern.ListMembers()
  • pfcSolid.ListFailedFeatures()
  • pfcSolid.ListFeaturesByType()
  • pfcSolid.GetFeatureById()
  • pfcBaseSession.QueryFeatureEdit()
  • The methods pfcFeature.ListChildren() and pfcFeature.ListParents() return an array of features that contain all the children or parents of the specified feature.
    The property pfcFeature.GroupDirectHeader returns the direct header of the group.
    To get the first feature in the specified group access the property pfcFeatureGroup.GroupLeader.
    The method pfcFeaturePattern.PatternLeader() and the method pfcFeaturePattern.ListMembers() return features that make up the specified feature pattern. See the section Feature Groups and Patterns for more information on feature patterns.
    The method pfcSolid.ListFailedFeatures() returns an array that contains all the features that failed regeneration.
    The method pfcSolid.ListFeaturesByType() returns an array of features contained in the model. You can specify which type of feature to collect by passing in one of the pfcFeatureType enumeration objects, or you can collect all features by passing void null as the type. If you list all features, the resulting array includes invisible features that Creo Parametric creates internally. Internal features are invisible features used internally for construction purposes. Use the ’s VisibleOnly argument to exclude them. If the argument VisibleOnly is True, the method lists the public features only. If the argument is False, the method lists both public and internal features.
    The method pfcSolid.GetFeatureById() returns the feature object with the corresponding integer identifier.
    A feature can be edited with the Edit Definition command in Creo Parametric. The method pfcBaseSession.QueryFeatureEdit() returns a list of all the features that are currently being edited by the Edit Definition command.
    Feature Information
    Properties Introduced:
  • pfcFeature.FeatType
  • pfcFeature.Status
  • pfcFeature.IsVisible
  • pfcFeature.IsReadonly
  • pfcFeature.IsEmbedded
  • pfcFeature.Number
  • pfcFeature.FeatTypeName
  • pfcFeature.FeatSubType
  • pfcRoundFeat.IsAutoRoundMember
  • The enumeration classes pfcFeatureType and pfcFeatureStatus provide information for a specified feature. The following properties specify this information:
    •  pfcFeature.FeatType—Returns the type of a feature.
    •  pfcFeature.Status—Returns whether the feature is suppressed, active, or failed regeneration.
    The other properties that gather feature information include the following:
    •  pfcFeature.IsVisible —Identifies whether the specified feature is visible on the screen. The property distinguishes visible features from internal features. Internal features are invisible features used for construction purposes.
    •  pfcFeature.IsReadonly —Identifies whether the specified feature can be modified.
    •  pfcFeature.IsEmbedded —Specifies whether the specified feature is an embedded datum.
    •  pfcFeature.Number —Returns the feature regeneration number. This property returns void null if the feature is suppressed.
    The property pfcFeature.FeatTypeName returns a string representation of the feature type.
    The property pfcFeature.FeatSubType returns a string representation of the feature subtype, for example, "Extrude" for a protrusion feature.
    The property pfcRoundFeat.IsAutoRoundMember determines whether the specified round feature is a member of an Auto Round feature.
    Feature Operations
    Methods and Properties Introduced:
  • pfcSolid.ExecuteFeatureOps()
  • pfcFeature.CreateSuppressOp()
  • pfcSuppressOperation.Clip
  • pfcSuppressOperation.AllowGroupMembers
  • pfcSuppressOperation.AllowChildGroupMembers
  • pfcFeature.CreateDeleteOp()
  • pfcDeleteOperation.Clip
  • pfcDeleteOperation.AllowGroupMembers
  • pfcDeleteOperation.AllowChildGroupMembers
  • pfcDeleteOperation.KeepEmbeddedDatums
  • pfcFeature.CreateResumeOp()
  • pfcResumeOperation.WithParents
  • pfcFeature.CreateReorderBeforeOp()
  • pfcReorderBeforeOperation.BeforeFeat
  • pfcFeature.CreateReorderAfterOp()
  • pfcReorderAfterOperation.AfterFeat
  • The method pfcSolid.ExecuteFeatureOps() causes a sequence of feature operations to run in order. Feature operations include suppressing, resuming, reordering, and deleting features. The optional pfcRegenInstructions argument specifies whether the user can fix the model if a regeneration failure occurs.
    Note
    Regenerating models in resolve_mode is not supported. As a result, the method pfcSolid.ExecuteFeatureOps() is not supported anymore.
    Some of the operations have specific options that you can modify to control the operation:
    •  Clip—Specifies whether to delete or suppress all features after the selected feature. By default, this option is false.
    Use the properties pfcDeleteOperation.Clip and pfcSuppressOperation.Clip to modify this option.
    •  AllowGroupMembers—If this option is set to true and if the feature to be deleted or suppressed is a member of a group, then the feature will be deleted or suppressed out of the group. If this option is set to false, then the entire group containing the feature is deleted or suppressed. By default, this option is false. It can be set to true only if the option Clip is set to true.
    Use the properties pfcSuppressOperation.AllowGroupMembers and pfcDeleteOperation.AllowGroupMembers to modify this option.
    •  AllowChildGroupMembers—If this option is set to true and if the children of the feature to be deleted or suppressed are members of a group, then the children of the feature are individually deleted or suppressed out of the group. If this option is set to false, then the entire group containing the feature and its children are deleted or suppressed. By default, this option is false. It can be set to true only if the options Clip and AllowGroupMembers are set to true.
    Use the properties pfcSuppressOperation.AllowChildGroupMembers and pfcDeleteOperation.AllowChildGroupMembers to modify this option.
    •  KeepEmbeddedDatums—Specifies whether to retain the embedded datums stored in a feature while deleting the feature. By default, this option is false.
    Use the property pfcDeleteOperation.KeepEmbeddedDatums to modify this option.
    •  WithParents—Specifies whether to resume the parents of the selected feature.
    Use the property pfcResumeOperation.WithParents to modify this option.
    •  BeforeFeat—Specifies the feature before which you want to reorder the features.
    Use the property pfcReorderBeforeOperation.BeforeFeat to modify this option.
    •  AfterFeat—Specifies the feature after which you want to reorder the features.
    Use the property pfcReorderAfterOperation.AfterFeat to modify this option.
    Feature Groups and Patterns
    Patterns are treated as features in Creo Parametric. A feature type, FEATTYPE_PATTERN_HEAD, is used for the pattern header feature.
    Note
    The pattern header feature is not treated as a leader or a member of the pattern by the properties described in the following section.
    Methods and Properties Introduced:
  • pfcFeature.Group
  • pfcFeature.Pattern
  • pfcFeature.GetPatternByType()
  • pfcFeature.PatternStatus
  • pfcFeature.GroupStatus
  • pfcFeature.GroupPatternStatus
  • pfcSolid.CreateLocalGroup()
  • pfcFeatureGroup.Pattern
  • pfcFeatureGroup.GroupLeader
  • pfcFeaturePattern.PatternLeader
  • pfcFeaturePattern.ListMembers()
  • pfcFeaturePattern.Delete()
  • The property pfcFeature.Group returns a handle to the local group that contains the specified feature.
    To get the first feature in the specified group call the property pfcFeatureGroup.GroupLeader.
    The property pfcFeaturePattern.PatternLeader and the method pfcFeaturePattern.ListMembers() return features that make up the specified feature pattern.
    A pattern is composed of a pattern header feature and a number of member features. You can pattern only a single feature. To pattern several features, create a local group and pattern this group.
    You can also create a pattern of pattern. This creates a multiple level pattern. For a pattern of pattern, the method pfcFeaturePattern.ListMembers() returns all the pattern header features created at the first level.
    For example, consider a model in which there is a pattern such as in the following Model Tree:
    Image
    The method pfcFeaturePattern.ListMembers() returns the pattern header features with the following IDs for a pattern of pattern:
    •  119
    •  177
    •  221
    •  265
    The properties pfcFeature.Pattern and pfcFeatureGroup.Pattern return the pfcFeaturePattern object that contains the corresponding pfcFeature or pfcFeatureGroup. Use the method pfcSolid.CreateLocalGroup() to take a sequence of features and create a local group with the specified name. To delete a pfcFeaturePattern object, call the method pfcFeaturePattern.Delete().
    The method pfcFeature.GetPatternByType() returns the pattern of the feature and is specified using the enumerated data type pfcPatternType. The valid values are:
    •  PATTERN_FEAT—Feature pattern.
    •  PATTERN_GROUP—Group pattern.
    The property pfcFeature.PatternStatus returns the pattern status of the feature and is specified using the enumerated data type pfcPatternStatus. The valid values are:
    •  GRP_PATTERN_NONE—Feature does not belong to any pattern.
    •  GRP_PATTERN_LEADER—Feature is leader of the pattern.
    •  GRP_PATTERN_MEMBER—Feature is member of the pattern.
    •  GRP_PATTERN_HEADER—Feature is header of the pattern.
    The property pfcFeature.GroupStatus returns the group status of the feature and is specified using the enumerated data type pfcupStatus. The valid values are:
    •  GROUP_NONE—Feature does not belong to any group.
    •  GROUP_MEMBER—Feature is member of the group.
    The property pfcFeature.GroupPatternStatus returns the group pattern status of the feature and is specified using the enumerated data type GroupPatternStatus. The valid values are:
    •  GRP_PATTERN_NONE—Feature does not belong to any group pattern.
    •  GRP_PATTERN_LEADER—Feature is leader of the group pattern.
    •  GRP_PATTERN_MEMBER—Feature is member of the group pattern.
    •  GRP_PATTERN_HEADER—Feature is header of the group pattern.
    Feature Groups
    Feature groups have a group header feature, which shows up in the model information and feature list for the model. This feature will be inserted in the regeneration list to a position just before the first feature in the group.
    The results of the header feature are as follows:
    •  Models that contain groups get one extra feature in the regeneration list, of type FEATTYPE_GROUP_HEAD. This affects the feature numbers of all subsequent features, including those in the group.
    •  Each group automatically contains the header feature in the list of features returned from pfcFeatureGroup.ListMembers().
    •  Each group automatically gets the group head feature as the leader. This is returned from pfcFeatureGroup.GroupLeader.
    •  Each group pattern contains a series of groups, and each group in the pattern is similarly constructed.
    User Defined Features
    Groups in Creo Parametric represent sets of contiguous features that act as a single feature for specific operations. Individual features are affected by most operations while some operations apply to an entire group:
    •  Suppress
    •  Delete
    •  Layers
    •  Patterning
    User Defined Features (UDFs) are groups of features that are stored in a file. When a UDF is placed in a new model the created features are automatically assigned to a group. A local group is a set of features that are specifically assigned to a group to make modifications and patterning easier.
    Note
    All methods in this section can be used for UDFs and local groups.
    Read Access to Groups and User Defined Features
    Methods and Properties Introduced:
  • pfcFeatureGroup.UDFName
  • pfcFeatureGroup.UDFInstanceName
  • pfcFeatureGroup.ListUDFDimensions()
  • pfcUDFDimension.UDFDimensionName
  • User defined features (UDFs) are groups of features that can be stored in a file and added to a new model. A local group is similar to a UDF except it is available only in the model in which is created.
    The property pfcFeatureGroup.UDFName provides the name of the group for the specified group instance. A particular group definition can be used more than once in a particular model.
    If the group is a family table instance, the property pfcFeatureGroup.UDFInstanceName supplies the instance name.
    The method pfcFeatureGroup.ListUDFDimensions() traverses the dimensions that belong to the UDF. These dimensions correspond to the dimensions specified as variables when the UDF was created. Dimensions of the original features that were not variables in the UDF are not included unless the UDF was placed using the Independent option.
    The property pfcUDFDimension.UDFDimensionName provides access to the dimension name specified when the UDF was created, and not the name of the dimension in the current model. This name is required to place the UDF programmatically using the method pfcSolid.CreateUDFGroup().
    Creating Features from UDFs
    Method Introduced:
  • pfcSolid.CreateUDFGroup()
  • The method pfcSolid.CreateUDFGroup() is used to create new features by retrieving and applying the contents of an existing UDF file. It is equivalent to the Creo Parametric command Feature, Create, User Defined.
    To understand the following explanation of this method, you must have a good knowledge and understanding of the use of UDFs in Creo Parametric. PTC recommends that you read about UDFs in the Creo Parametric help, and practice defining and using UDFs in Creo Parametric before you attempt to use this method.
    When you create a UDF interactively, Creo Parametric prompts you for the information it needs to fix the properties of the resulting features. When you create a UDF from Creo.JS, you can provide some or all of this information programmatically by filling several compact data classes that are inputs to the method pfcSolid.CreateUDFGroup().
    During the call to pfcSolid.CreateUDFGroup(), Creo Parametric prompts you for the following:
    •  Information required by the UDF that was not provided in the input data structures.
    •  Correct information to replace erroneous information
    Such prompts are a useful way of diagnosing errors when you develop your application. This also means that, in addition to creating UDFs programmatically to provide automatic synthesis of model geometry, you can also use pfcSolid.CreateUDFGroup() to create UDFs semiinteractively. This can simplify the interactions needed to place a complex UDF making it easier for the user and less prone to error.
    Creating UDFs
    Creating a UDF requires the following information:
    •  Name—The name of the UDF you are creating and the instance name if applicable.
    •  Dependency—Specify if the UDF is independent of the UDF definition or is modified by the changers made to it.
    •  Scale—How to scale the UDF relative to the placement model.
    •  Variable Dimension—The new values of the variables dimensions and pattern parameters, those whose values can be modified each time the UDF is created.
    •  Dimension Display—Whether to show or blank nonvariable dimensions created within the UDF group.
    •  References—The geometrical elements that the UDF needs in order to relate the features it contains to the existing models features. The elements correspond to the selections that Creo Parametric prompts you for when you create a UDF interactively using the prompts defined when the UDF was created. You cannot select an embedded datum as the UDF reference.
    •  Parts Intersection—When a UDF that is being created in an assembly contains features that modify the existing geometry you must define which parts are affected or intersected. You also need to know at what level in an assembly each intersection is going to be visible.
    •  Orientations—When a UDF contains a feature with a direction that is defined in respect to a datum plane Creo Parametric must know what direction the new feature points to. When you create such a UDF interactively Creo Parametric prompts you for this information with a flip arrow.
    •  Quadrants—When a UDF contains a linearly placed feature that references two datum planes to define its location in the new model Creo Parametric prompts you to select the location of the new feature. This is determined by which side of each datum plane the feature must lie. This selection is referred to as the quadrant because there are four possible combinations for each linearly place feature.
    To pass all the above values to Creo Parametric, Creo.JS uses a special class that prepares and sets all the options and passes them to Creo Parametric.
    Creating Interactively Defined UDFs
    Method Introduced:
  • pfcUDFPromptCreateInstructions.Create()
  • This static method is used to create an instructions object that can be used to prompt a user for the required values that creates a UDF interactively.
    Creating a Custom UDF
    Method Introduced:
  • pfcUDFCustomCreateInstructions.Create()
  • This method creates a pfcUDFCustomCreateInstructions object with a specified name. To set the UDF creation parameters programmatically you must modify this object as described below. The members of this class relate closely to the prompts Creo Parametric gives you when you create a UDF interactively. PTC recommends that you experiment with creating the UDF interactively using Creo Parametric before you write the Creo.JS code to fill the structure.
    Setting the Family Table Instance Name
    Property Introduced:
  • pfcUDFCustomCreateInstructions.InstanceName
  • If the UDF contains a family table, this field can be used to select the instance in the table. If the UDF does not contain a family table, or if the generic instance is to be selected, the do not set the string.
    Setting Dependency Type
    Property Introduced:
  • pfcUDFCustomCreateInstructions.DependencyType
  • The pfcUDFDependencyType object represents the dependency type of the UDF. The choices correspond to the choices available when you create a UDF interactively. This enumerated type takes the following values:
    •  UDFDEP_INDEPENDENT
    •  UDFDEP_DRIVEN
    Note
    UDFDEP_INDEPENDENT is the default value, if this option is not set.
    Setting Scale and Scale Type
    Properties Introduced:
  • pfcUDFCustomCreateInstructions.ScaleType
  • pfcUDFCustomCreateInstructions.Scale
  • The property pfcUDFCustomCreateInstructions.ScaleType specifies the length units of the UDF in the form of the pfcUDFScaleType object. This enumerated type takes the following values:
    •  UDFSCALE_SAME_SIZE
    •  UDFSCALE_SAME_DIMS
    •  UDFSCALE_CUSTOM
    •  UDFSCALE_nil
    Note
    The default value is UDFSCALE_SAME_SIZE if this option is not set.
    The property pfcUDFCustomCreateInstructions.Scale specifies the scale factor. If the value of the filed ScaleType is set to UDFSCALE_CUSTOM, the property pfcUDFCustomCreateInstructions.Scale assigns the user defined scale factor. Otherwise, this attribute is ignored.
    Setting the Appearance of the Non UDF Dimensions
    Property Introduced:
  • pfcUDFCustomCreateInstructions.DimDisplayType
  • The pfcUDFDimensionDisplayType object sets the options in Creo Parametric for determining the appearance in the model of UDF dimensions and pattern parameters that were not variable in the UDF, and therefore cannot be modified in the model. This enumerated type takes the following values:
    •  UDFDISPLAY_NORMAL
    •  UDFDISPLAY_READ_ONLY
    •  UDFDISPLAY_BLANK
    Note
    The default value is UDFDISPLAY_NORMAL if this option is not set.
    The values defined by the enumerated data type pfcUDFDimensionDisplayType correspond to the options in Creo Parametric for determining the appearance of the UDF dimensions and pattern parameters that were not variable in the UDF, and therefore cannot be modified in the model.
    Setting the Variable Dimensions and Parameters
    Methods and Properties Introduced:
  • pfcUDFCustomCreateInstructions.VariantValues
  • pfcUDFVariantDimension.Create()
  • pfcUDFVariantDimension.DimensionValue
  • pfcUDFVariantPatternParam.Create()
  • pfcUDFVariantPatternParam.PatternParam
  • pfcUDFVariantValues class represents an array of variable dimensions and pattern parameters.
    pfcUDFVariantDimension.Create() is a static method creating a pfcUDFVariantDimension. It accepts the following parameters:
    •  Name—The symbol that the dimension had when the UDF was originally defined, not the prompt that the UDF uses when it is created interactively. To make this name easy to remember, before you define the UDF that you plan to create with the Creo.JS, you should modify the symbols of all the dimensions that you want to select to be variable. If you get the name wrong, pfcSolid.CreateUDFGroup() will not recognize the dimension and prompts the user for the value in the usual way and does not modify the value.
    •  DimensionValue—The new value.
    Use the property pfcUDFVariantDimension.DimensionValue to specify the dimension value.
    If you do not remember the name, you can find it by creating the UDF interactively in a test model, then using the pfcFeatureGroup.ListUDFDimensions() and pfcUDFDimension.UDFDimensionName to find out the name.
    pfcUDFVariantPatternParam.Create() is a static method which creates a pfcUDFVariantPatternParam. It accepts the following parameters:
    •  Name—The string name that the pattern parameter had when the UDF was originally defined
    •  PatternParam—The new value.
    Use the property pfcUDFVariantPatternParam.PatternParam to specify the parameter value.
    After the pfcUDFVariantValues object has been compiled, use pfcUDFCustomCreateInstructions.VariantValues to add the variable dimensions and parameters to the instructions.
    Setting the User Defined References
    Methods and Properties Introduced:
  • pfcUDFReference.Create()
  • pfcUDFReference.IsExternal
  • pfcUDFReference.ReferenceItem
  • pfcUDFCustomCreateInstructions.References
  • pfcUDFReference.Create() is a static method and it creates a pfcUDFReference object. It accepts the following parameters:
    •  PromptForReference—The prompt defined for this reference when the UDF was originally set up. It indicates which reference this structure is providing. If you get the prompt wrong, pfcSolid.CreateUDFGroup() will not recognize it and prompts the user for the reference in the usual way.
    •  ReferenceItem—Specifies the pfcSelection object representing the referenced element. You can set pfcSelection programmatically or prompt the user for a selection separately. You cannot set an embedded datum as the UDF reference.
    There are two types of reference:
      Internal—The referenced element belongs directly to the model that will contain the UDF. For an assembly, this means that the element belongs to the top level.
      External—The referenced element belongs to an assembly member other than the placement member.
    To set the reference type, use the property pfcUDFReference.IsExternal.
    To set the item to be used for reference, use the property pfcUDFReference.ReferenceItem.
    After the pfcUDFReference object has been set, use pfcUDFCustomCreateInstructions.References to add the program-defined references.
    Setting the Assembly Intersections
    Methods and Properties Introduced:
  • pfcUDFAssemblyIntersection.Create()
  • pfcUDFAssemblyIntersection.ComponentPath
  • pfcUDFAssemblyIntersection.VisibilityLevel
  • pfcUDFAssemblyIntersection.InstanceNames
  • pfcUDFCustomCreateInstructions.Intersections
  • pfcUDFAssemblyIntersection.Create() is a static method. Use this method to create a pfcUDFReference object. It accepts the following parameters:
    •  ComponentPath—Is an intpath type object representing the component path of the part to be intersected.
    •  VisibilityLevel—The number that corresponds to the visibility level of the intersected part in the assembly. If the number is equal to the length of the component path the feature is visible in the part that it intersects. If VisibilityLevel is 0, the feature is visible at the level of the assembly containing the UDF.
    The property pfcUDFAssemblyIntersection.ComponentPath sets the member identifier table that defines the location of the intersected part in the assembly that contains the UDF.
    The property pfcUDFAssemblyIntersection.VisibilityLevel sets the length of the pfcComponentPath object that corresponds to the visibility level of the intersected part in the assembly.
    pfcUDFAssemblyIntersection.InstanceNames sets an array of names for the new instances of parts created to represent the intersection geometry.
    After the pfcUDFAssemblyIntersections object is set, use pfcUDFCustomCreateInstructions.Intersections to add the assembly intersections.
    Setting Orientations
    Property Introduced:
  • pfcUDFCustomCreateInstructions.Orientations
  • pfcUDFOrientations class represents an array of orientations that provide the answers to Creo Parametric prompts that use a flip arrow. Each term is a pfcUDFOrientation object that takes the following values:
    •  UDFORIENT_INTERACTIVE—Prompt for the orientation using a flip arrow.
    •  UDFORIENT_NO_FLIP—Accept the default flip orientation.
    •  UDFORIENT_FLIP—Invert the orientation from the default orientation.
    The order of orientations should correspond to the order in which Creo Parametric prompts for them when the UDF is created interactively. If you do not provide an orientation that Creo Parametric needs, it uses the default value NO_FLIP.
    After the pfcUDFOrientations object is set, use pfcUDFOrientation to add the orientations.
    Setting Quadrants
    Property Introduced:
  • pfcUDFCustomCreateInstructions.Quadrants
  • The property pfcUDFCustomCreateInstructions.Quadrants sets an array of points, which provide the X, Y, and Z coordinates that correspond to the prompt in Creo Parametric for selections related to feature positions. The order of quadrants should correspond to the order in which Creo Parametric prompts for them when the UDF is created interactively.
    Setting the External References
    Property Introduced:
  • pfcUDFCustomCreateInstructions.ExtReferences
  • The property pfcUDFCustomCreateInstructions.ExtReferences sets an external reference assembly to be used when placing the UDF. This is required when placing the UDF in the component using references outside of that component. References can be to the top-level assembly of another component.