Assemblies and Components
This section describes the Web.Link functions that access the functions of a Creo Parametric assembly. You must be familiar with the following before you read this section:
•  The Selection Object
•  Coordinate Systems
•  The Geometry section
Structure of Assemblies and Assembly Objects
The object pfcAssembly is an instance of pfcSolid. The pfcAssembly object can therefore be used as input to any of the pfcSolid and pfcModel methods applicable to assemblies. However assemblies do not contain solid geometry items. The only geometry in the assembly is datums (points, planes, axes, coordinate systems, curves, and surfaces). Therefore solid assembly features such as holes and slots will not contain active surfaces or edges in the assembly model.
The solid geometry of an assembly is contained in its components. A component is a feature of type pfcComponentFeat, which is a reference to a part or another assembly, and a set of parametric constraints for determining its geometrical location within the parent assembly.
Assembly features that are solid, such as holes and slots, and therefore affect the solid geometry of parts in the assembly hierarchy, do not themselves contain the geometry items that describe those modifications. These items are always contained in the parts whose geometry is modified, within local features created for that purpose.
The important Web.Link functions for assemblies are those that operate on the components of an assembly. The object pfcComponentFeat, which is an instance of pfcFeature is defined for that purpose. Each assembly component is treated as a variety of feature, and the integer identifier of the component is also the feature identifier.
An assembly can contain a hierarchy of assemblies and parts at many levels, in which some assemblies and parts may appear more than once. To identify the role of any database item in the context of the root assembly, it is not sufficient to have the integer identifier of the item and the handle to its owning part or assembly, as would be provided by its pfcFeature description.
It is also necessary to give the full path of the assembly-component references down from the root assembly to the part or assembly that owns the database item. This is the purpose of the object pfcComponentPath, which is used as the input to Web.Link assembly functions.
The following figure shows an assembly hierarchy with two examples of the contents of a pfcComponentPath object.
Image
In the assembly shown in the figure, subassembly C is component identifier 11 within assembly A, Part B is component identifier 3 within assembly AB, and so on. The subassembly AB occurs twice. To refer to the two occurrences of part B, use the following:
(?)Component BComponent B"
ComponentIds.Item(0) = 2   ComponentIds.Item(1) = 11
ComponentIds.Item(1) = 2   ComponentIds.Item(2) = 6
ComponentIds.Item(2) = 5   ComponentIds.Item(3) = 12
ComponentIds.Item(3) = 2   ComponentIds.Item(4) = 3
ComponentIds.Item(4) = 3
The object pfcComponentPath is one of the main portions of the pfcSelection object.
Assembly Components
Methods and Properties Introduced:
  • pfcComponentFeat.IsBulkitem
  • pfcComponentFeat.IsSubstitute
  • pfcComponentFeat.CompType
  • pfcComponentFeat.ModelDescr
  • pfcComponentFeat.IsPlaced
  • pfcComponentFeat.IsPackaged
  • pfcComponentFeat.IsUnderconstrained
  • pfcComponentFeat.IsFrozen
  • pfcComponentFeat.Position
  • pfcComponentFeat.CopyTemplateContents()
  • pfcComponentFeat.CreateReplaceOp()
  • The property pfcComponentFeat.IsBulkitem identifies whether an assembly component is a bulk item. A bulk item is a non-geometric assembly feature that should appear in an assembly bill of materials.
    The property pfcComponentFeat.IsSubstitute returns a true value if the component is substituted, else it returns a false. When you substitute a component in a simplified representation, you temporarily exclude the substituted component and superimpose the substituting component in its place.
    The property pfcComponentFeat.CompType enables you to set the type of the assembly component. The component type identifies the purpose of the component in a manufacturing assembly.
    The property pfcComponentFeat.ModelDescr returns the model descriptor of the component part or subassembly.
    Note
    From Pro/ENGINEER Wildfire 4.0 onwards, the property pfcComponentFeat.ModelDescr throws an exception pfcXtoolkitCantOpen if called on an assembly component whose immediate generic is not in session. Handle this exception and typecast the assembly component as pfcSolid, which in turn can be typecast as pfcFamilyMember, and use the method pfcFamilyMember.GetImmediateGenericInfo() to get the model descriptor of the immediate generic model. If you wish to switch off this behavior and continue to run legacy applications in the pre-Wildfire 4.0 mode, set the configuration option retrieve_instance_dependencies to instance_and_generic_deps.
    The property pfcComponentFeat.IsPlaced forces the component to be considered placed. The value of this parameter is important in assembly Bill of Materials.
    Note
    Once a component is constrained or packaged, it cannot be made unplaced again.
    A component of an assembly that is either partially constrained or unconstrained is known as a packaged component. Use the property pfcComponentFeat.IsPackaged to determine if the specified component is packaged.
    The property pfcComponentFeat.IsUnderconstrained determines if the specified component is underconstrained, that is, it possesses some constraints but is not fully constrained.
    The property pfcComponentFeat.IsFrozen determines if the specified component is frozen. The frozen component behaves similar to the packaged component and does not follow the constraints that you specify.
    The property pfcComponentFeat.Position retrieves the component’s initial position before constraints and movements have been applied. If the component is packaged this position is the same as the constraint’s actual position. This property modifies the assembly component data but does not regenerate the assembly component. To regenerate the component, use the method pfcComponentFeat.Regenerate().
    The method pfcComponentFeat.CopyTemplateContents() copies the template model into the model of the specified component.
    The method pfcComponentFeat.CreateReplaceOp() creates a replacement operation used to swap a component automatically with a related component. The replacement operation can be used as an argument to pfcSolid.ExecuteFeatureOps().
    Example Code: Replacing Instances
    The sample code in the file pfcComponentFeatExamples.js located at <creo_weblink_loadpoint>/weblinkexamples/jscript contains a single static utility method. This method takes an assembly for an argument. It searches through the assembly for all components that are instances of the model "bolt". It then replaces all such occurrences with a different instance of bolt.
    Regenerating an Assembly Component
    Method Introduced:
  • pfcComponentFeat.Regenerate()
  • The method pfcComponentFeat.Regenerate() regenerates an assembly component. The method regenerates the assembly component just as in an interactive Creo Parametric session.
    Creating a Component Path
    Methods Introduced
  • MpfcAssembly.CreateComponentPath()
  • The method MpfcAssembly.CreateComponentPath() returns a component path object, given the Assembly model and the integer id path to the desired component.
    Component Path Information
    Methods and Properties Introduced:
  • pfcComponentPath.Root
  • pfcComponentPath.ComponentIds
  • pfcComponentPath.Leaf
  • pfcComponentPath.GetTransform()
  • pfcComponentPath.SetTransform()
  • pfcComponentPath.GetIsVisible()
  • The property pfcComponentPath.Root returns the assembly at the head of the component path object.
    The property pfcComponentPath.ComponentIds returns the sequence of ids which is the path to the particular component.
    The property pfcComponentPath.Leaf returns the solid model at the end of the component path.
    The method pfcComponentPath.GetTransform() returns the coordinate system transformation between the assembly and the particular component. It has an option to provide the transformation from bottom to top, or from top to bottom. This method describes the current position and the orientation of the assembly component in the root assembly.
    The method pfcComponentPath.SetTransform() applies a temporary transformation to the assembly component, similar to the transformation that takes place in an exploded state. The transformation will only be applied if the assembly is using DynamicPositioning.
    The method pfcComponentPath.GetIsVisible() identifies if a particular component is visible in any simplified representation.
    Assembling Components
    Methods Introduced:
  • pfcAssembly.AssembleComponent()
  • pfcAssembly.AssembleByCopy()
  • pfcComponentFeat.GetConstraints()
  • pfcComponentFeat.SetConstraints()
  • pfcComponentFeat.GetConstraintsWithCompPath()
  • The method pfcAssembly.AssembleComponent() adds a specified component model to the assembly at the specified initial position. The position is specified in the format defined by the class pfcTransform3D. Specify the orientation of the three axes and the position of the origin of the component coordinate system, with respect to the target assembly coordinate system.
    Note
    If the transform matrix passed as the initial position of the component is incorrect and non-orthonormal, the method pfcAssembly.AssembleComponent() returns the error pfcExceptions.pfcXToolkitBadInputs. In such scenario, you can use the method MpfcBase.MakeMatrixOrthonormal() to convert this non-orthonormal matrix to an orthonormal matrix.
    The method pfcAssembly.AssembleByCopy() creates a new component in the specified assembly by copying from the specified component. If no model is specified, then the new component is created empty. The input parameters for this method are:
    •  LeaveUnplaced—If true the component is unplaced. If false the component is placed at a default location in the assembly. Unplaced components belong to an assembly without being assembled or packaged. These components appear in the model tree, but not in the graphic window. Unplaced components can be constrained or packaged by selecting them from the model tree for redefinition. When its parent assembly is retrieved into memory, an unplaced component is also retrieved.
    •  ModelToCopy—Specify the model to be copied into the assembly
    •  NewModelName—Specify a name for the copied model
    The method pfcComponentFeat.GetConstraints() retrieves the constraints for a given assembly component.
    The method pfcComponentFeat.SetConstraints() allows you to set the constraints for a specified assembly component. The input parameters for this method are:
    •  Constraints—Constraints for the assembly component. These constraints are explained in detail in the later sections.
    •  ReferenceAssembly—The path to the owner assembly, if the constraints have external references to other members of the top level assembly. If the constraints are applied only to the assembly component then the value of this parameter should be null.
    This method modifies the component feature data and regenerates the assembly component.
    The method pfcComponentFeat.GetConstraintsWithCompPath() retrieves the constraints for a given assembly component using the input argument CompPath which is the path to the owner assembly. Pass this input argument CompPath, if the constraints have references to other members of the top level assembly. Pass it as Null, if the constraints have references only to the owner assembly.
    Constraint Attributes
    Methods and Properties Introduced:
  • pfcConstraintAttributes.Create()
  • pfcConstraintAttributes.Force
  • pfcConstraintAttributes.Ignore
  • The method pfcConstraintAttributes.Create() returns the constraint attributes object based on the values of the following input parameters:
    •  Ignore—Constraint is ignored during regeneration. Use this capability to store extra constraints on the component, which allows you to quickly toggle between different constraints.
    •  Force—Constraint has to be forced for line and point alignment.
    •  None—No constraint attributes. This is the default value.
    Assembling a Component Parametrically
    You can position a component relative to its neighbors (components or assembly features) so that its position is updated as its neighbors move or change. This is called parametric assembly. Creo Parametric allows you to specify constraints to determine how and where the component relates to the assembly. You can add as many constraints as you need to make sure that the assembly meets the design intent.
    Methods and Properties Introduced:
  • pfcComponentConstraint.Create()
  • pfcComponentConstraint.Type
  • pfcComponentConstraint.AssemblyReference
  • pfcComponentConstraint.AssemblyDatumSide
  • pfcComponentConstraint.ComponentReference
  • pfcComponentConstraint.ComponentDatumSide
  • pfcComponentConstraint.Offset
  • pfcComponentConstraint.Attributes
  • pfcComponentConstraint.UserDefinedData
  • The method pfcComponentConstraint.Create() returns the component constraint object having the following parameters:
    •  ComponentConstraintType—Using the TYPE options, you can specify the placement constraint types. They are as follows:
      ASM_CONSTRAINT_MATE—Use this option to make two surfaces touch one another, that is coincident and facing each other.
      ASM_CONSTRAINT_MATE_OFF—Use this option to make two planar surfaces parallel and facing each other.
      ASM_CONSTRAINT_ALIGN—Use this option to make two planes coplanar, two axes coaxial and two points coincident. You can also align revolved surfaces or edges.
      ASM_CONSTRAINT_ALIGN_OFF—Use this option to align two planar surfaces at an offset.
      ASM_CONSTRAINT_INSERT—Use this option to insert a "male" revolved surface into a ``female'' revolved surface, making their respective axes coaxial.
      ASM_CONSTRAINT_ORIENT—Use this option to make two planar surfaces to be parallel in the same direction.
      ASM_CONSTRAINT_CSYS—Use this option to place a component in an assembly by aligning the coordinate system of the component with the coordinate system of the assembly.
      ASM_CONSTRAINT_TANGENT—Use this option to control the contact of two surfaces at their tangents.
      ASM_CONSTRAINT_PNT_ON_SRF—Use this option to control the contact of a surface with a point.
      ASM_CONSTRAINT_EDGE_ON_SRF—Use this option to control the contact of a surface with a straight edge.
      ASM_CONSTRAINT_DEF_PLACEMENT—Use this option to align the default coordinate system of the component to the default coordinate system of the assembly.
      ASM_CONSTRAINT_SUBSTITUTE—Use this option in simplified representations when a component has been substituted with some other model
      ASM_CONSTRAINT_PNT_ON_LINE—Use this option to control the contact of a line with a point.
      ASM_CONSTRAINT_FIX—Use this option to force the component to remain in its current packaged position.
      ASM_CONSTRAINT_AUTO—Use this option in the user interface to allow an automatic choice of constraint type based upon the references.
      ASM_CONSTRAINT_EXPLICIT
    •  AssemblyReference—A reference in the assembly.
    •  AssemblyDatumSide—Orientation of the assembly. This can have the following values:
      Yellow—The primary side of the datum plane which is the default direction of the arrow.
      Red—The secondary side of the datum plane which is the direction opposite to that of the arrow.
    •  ComponentReference—A reference on the placed component.
    •  ComponentDatumSide—Orientation of the assembly component. This can have the following values:
      Yellow—The primary side of the datum plane which is the default direction of the arrow.
      Red—The secondary side of the datum plane which is the direction opposite to that of the arrow.
    •  Offset—The mate or align offset value from the reference.
    •  Attributes—Constraint attributes for a given constraint
    •  UserDefinedData—A string that specifies user data for the given constraint.
    Use the properties listed above to access the parameters of the component constraint object.
    Redefining and Rerouting Assembly Components
    These functions enable you to reroute previously assembled components, just as in an interactive Creo Parametric session.
    Methods Introduced:
  • pfcComponentFeat.RedefineThroughUI()
  • pfcComponentFeat.MoveThroughUI()
  • The method pfcComponentFeat.RedefineThroughUI() must be used in interactive Web.Link applications. This method displays the Creo Parametric Constraint dialog box. This enables the end user to redefine the constraints interactively. The control returns to Web.Link application when the user selects OK or Cancel and the dialog box is closed.
    The method pfcComponentFeat.MoveThroughUI() invokes a dialog box that prompts the user to interactively reposition the components. This interface enables the user to specify the translation and rotation values. The control returns to Web.Link application when the user selects OK or Cancel and the dialog box is closed.
    Example: Component Constraints
    The sample code in the file pfcComponentFeatExamples.js located at <creo_weblink_loadpoint>/weblinkexamples/jscript displays each constraint of the component visually on the screen, and includes a text explanation for each constraint.
    Example: Assembling Components
    The sample code in the file pfcComponentFeatExamples.js located at <creo_weblink_loadpoint>/weblinkexamples/jscript demonstrates how to assemble a component into an assembly, and how to constrain the component by aligning datum planes. If the complete set of datum planes is not found, the function will show the component constraint dialog to the user to allow them to adjust the placement.
    Exploded Assemblies
    These methods enable you to determine and change the explode status of the assembly object.
    Methods and Properties Introduced:
  • pfcAssembly.IsExploded
  • pfcAssembly.Explode()
  • pfcAssembly.UnExplode()
  • pfcAssembly.GetActiveExplodedState()
  • pfcAssembly.GetDefaultExplodedState()
  • pfcExplodedState.Activate()
  • The methods pfcAssembly.IsExploded and pfcAssembly.Explode() enable you to determine and change the explode status of the assembly object.
    The property pfcAssembly.IsExploded reports whether the specified assembly is currently exploded. Use this property in the assembly mode only. The exploded status of an assembly depends on the mode. If an assembly is opened in the drawing mode, the state of the assembly in the drawing view is displayed. The drawing view does not represent the actual exploded state of the assembly.
    The method pfcAssembly.GetActiveExplodedState() returns the current active explode state.
    The method pfcAssembly.GetDefaultExplodedState() returns the default explode state.
    The method pfcExplodedState.Activate() activates the specified explode state representation.
    Skeleton Models
    Skeleton models are a 3-dimensional layout of the assembly. These models are holders or distributors of critical design information, and can represent space requirements, important mounting locations, and motion.
    Methods and Properties Introduced:
  • pfcAssembly.AssembleSkeleton()
  • pfcAssembly.AssembleSkeletonByCopy()
  • pfcAssembly.GetSkeleton()
  • pfcAssembly.DeleteSkeleton()
  • pfcSolid.IsSkeleton
  • The method pfcAssembly.AssembleSkeleton() adds an existing skeleton model to the specified assembly.
    The method pfcAssembly.GetSkeleton() returns the skeleton model of the specified assembly.
    The method pfcAssembly.DeleteSkeleton() deletes a skeleton model component from the specified assembly.
    The method pfcAssembly.AssembleSkeletonByCopy() adds a specified skeleton model to the assembly. The input parameters for this method are:
    •  SkeletonToCopy—Specify the skeleton model to be copied into the assembly
    •  NewSkeletonName—Specify a name for the copied skeleton model
    The property pfcSolid.IsSkeleton determines if the specified part model is a skeleton model or a concept model. It returns a true if the model is a skeleton else it returns a false.