Solid Bodies
The methods in this chapter allow a Creo Object TOOLKIT C++ application to access, modify, and create geometric solid bodies in a model. We recommend that you study the Creo Parametric documentation on solid bodies, and develop experience with manipulating geometric solid bodies using the Creo Parametric commands before attempting to use these methods.
Solid Body Information
The state of the body is derived from the features and geometry in which the body is created.
Methods introduced:
The method pfcSolidBody::GetBodyState specifies the state of the body using the enumerated type pfcSolidBodyState. The valid values are:
•  pfcBODY_STATE_MISSING
•  pfcBODY_STATE_CONSUMED—Shows bodies that are removed by the Remove Body command, or the bodies that are merged, subtracted, or intersected during Boolean operations. Such bodies do not contribute in the mass properties calculations.
•  pfcBODY_STATE_NO_CONTR_FEAT—Shows bodies that are created using the New Body command, or the bodies with geometry that is deleted, suppressed, or rerouted to different bodies.
•  pfcBODY_STATE_NO_GEOMETRY—Shows bodies in which the entire geometry is removed by some features or show bodies that have contributing features but no geometry.
•  pfcBODY_STATE_ACTIVE
The method pfcSolidBody::IsConstruction checks if the body is a construction body. The method returns a True if solid body is a construction body.
The method pfcSolidBody::ListSurfaces lists all the surfaces in the specified body
The method pfcSolid::GetDefaultBody returns the default body in the specified solid.
The method pfcSolidBody::GetFeatures lists the features that are associated with the specified body.
Use the method pfcSolidBody::GetOutline to retrieve the regeneration outline of a solid body, with respect to the base coordinate system orientation. This outline defines the boundary box of the body.
The method pfcSolidBody::IsSheetmetal checks if the specified body is an active sheetmetal body.
The method pfcSolidBody::GetDensity determines the density of the body.
Use the method pfcSolidBody::GetMassProperty to retrieve the mass properties of a body in the specified coordinate system.
Creating a Solid Body
The object wfcWSolidBody represents a solid body.
Methods Introduced:
The method wfcWSolid::CreateBody creates a new body in the specified solid.
The method wfcWSolid::DeleteBody deletes the specified body in the solid.
The method wfcWSolidBody::SetDefault sets the solid body as a default body.
The method wfcWSolidBody::SetConstruction sets the solid body as a construction body.
External Copy Geometry Feature
The external Copy Geometry feature copies geometry from model to model without copying the geometry in the context of the assembly. Dependency on the assembly and all models along the path between the two components is avoided. When a Copy Geometry feature is created in Part mode, it is automatically defined as external. Source and target components must be relatively positioned, but are independent of the assembly context.
When all the components are assembled, the copied geometry of the target models is coincident to the referenced geometry of the external model. Components can be deleted from the assembly without losing associativity of copied geometry, which happens with internal Copy Geometry features when the target component model is deleted. In addition, none of the other external Copy Geometry features that reference the component will fail.
An independent external Copy Geometry feature remains frozen in its original state, whether or not its external reference model is in session and its geometry has been updated. It does not fail when copied references are missing from the parent model.
If the external reference model is an assembly, all the geometric references must be chosen from the same model. The first selection determines which model this will be. If the first reference is selected from geometry, an assembly surface, datum, and so forth of the top-level assembly, all subsequent references must be from top-level assembly geometry. If the first reference is chosen from an assembly component model, all subsequent reference selections must be made from that model.
Copy Geometry features can copy reference geometry such as
•  Surface
•  Datum features
•  Edges
•  Curves
•  Bodies
They are used in a top-down design to reduce the amount of data in a session, thus avoiding the retrieval of entire reference source models.
You can define the properties of the copied references to include in the Copy Geometry feature. All properties in the list that follows are copied by default. You can then decide which properties you do not want to copy to the target.
•  Appearance—Appearances from the source geometry and applies them to the copied geometry.
•  Parameters—Parameters of the copied entities.
•  Names—Names. When cleared, generic names are provided for copied entities.
•  Layers—Layer assignment and places the copied entities on layers with the same name when they exist in the target part.
•  Materials—Material assignment is available only for bodies. When the material does not exist in the target part, it is copied to the target part and assigned to the newly created body. When cleared, the newly created body is assigned the master material of the target part and you can explicitly assign a material to the copied body in the target.
Note
Mass properties are copied along with materials.
•  Construction Bodies—Construction attribute is available only for bodies, whether the body is a construction body or not.
To create a multibody part from an assembly
1. Set the callback action for Assembly To MultiBody.
2. Use the method pfcBaseSession::CreatePart to create a new empty part.
3. Visit all bodies from the part in an assembly. For each part, a new body is created in the empty part.
4. Select the bodies using the global method pfcCreateModelSelection.
5. Copy external geometry from the part to the body.
6. Use the element tree for Body Copy Options to copy the body copy options from part to the body.
7. The part is displayed in the new window using the method pfcModel::DisplayInNewWindow.
8. Use the method pfcBaseSession::GetModelWindow to get the details of the window in which the model is displayed.
Example 1: Creating a multibody part from an assembly
The sample code in OTKMultiBody.cxx located at <creo_otk_loadpoint_app>/otk_examples/otk_examples_solid illustrates how to create a multibody part from an assembly.
To create an assembly from a multibody part
1. Set the callback action for MultiBody To Assembly
2. Collect bodies from part or component part using the pfcSelections class.
3. Build an element tree for body copy option. For more information about element tree for body options, refer to the “The Element Tree for Body Options” chapter in the Creo Parametric TOOLKIT Users’ Guide.
4. For each body, an empty part is created and the geometry of the bodies is copied to the respective parts, through the external copy geometry feature and the body copy options.
5. Create an assembly from the parts.
6. The assembly is displayed in the new window using the method pfcModel::DisplayInNewWindow.
7. Use the method pfcBaseSession::GetModelWindow to get the details of the window in which the model is displayed.
Example 2: Creating an assembly from a multibody part
The sample code in OTKMultiBody.cxx located at <creo_otk_loadpoint_app>/otk_examples/otk_examples_solid illustrates how to create an assembly from a multibody part.
To set the appearance of bodies
The appearance of a material of a body is based on information such as:
•  Color
•  Highlight
•  Reflection
•  Transparency
You can apply and clear appearances to and from a body.
1. Set the callback action for Identify bodies & Apply Appearance and Restore bodies.
2. Use the method pfcBaseSession::GetCurrentWindow to get the information of the current Creo Parametric window.
3. Apply different colors to all bodies in a part using the method wfcWSelection::SetVisibleAppearance.
4. Restore colors to all bodies in a part using the method wfcWSelection:GetVisibleAppearance.
Example 3: Identifying bodies or applying appearance to bodies
The sample code in OTKMultiBody.cxx located at <creo_otk_loadpoint_app>/otk_examples/otk_examples_solid illustrates how to apply appearance to bodies