
Tue, 08/26/2025 - 13:17
While reading a STEP file, I’ve created a tree data structure representing assemblies and parts.
An assembly can contain sub-assemblies and parts.
A part is always the last node in the hierarchy.
For assemblies, I save the label using:
auto shape = XCAFDoc_ShapeTool::GetShape(assmLabel).Located(loc, Standard_False);
assm->m_shape = new AIS_AnnotableColoredShape(shape);
(where AIS_AnnotableColoredShape is derived from AIS_ColoredShape).
For parts, I can select the AIS_Shape from the viewer and apply transformations like this:
gp_Trsf rot;
rot.SetRotation(ax, M_PI / 2.0); // 90 degrees
gp_Trsf newLoc = rot * aAIS->LocalTransformation();
aAIS->SetLocalTransformation(newLoc);
Problem: For assemblies, I cannot select the AIS_Shape in the same way.
I want to apply a transformation to the assembly as a whole—specifically, rotate it around the Y-axis at its origin.
Thu, 09/18/2025 - 18:25
hi, try To apply a transformation to the entire assembly, you need to apply it to all of the components within the assembly. Here's how you can do it:
Transformations on Assemblies: Since assemblies contain parts and potentially other sub-assemblies, you can apply a transformation to the whole assembly by traversing the tree and applying the transformation to each part and sub-assembly individually.
Applying a Transformation to All Components:
Step 1: Traverse your tree structure to identify all the components (both parts and sub-assemblies) that belong to the assembly.
Step 2: For each component (part or sub-assembly), get its AIS_Shape (or equivalent shape object) and apply the transformation. If it's a sub-assembly, recursively apply the transformation to its components.