
Fri, 12/13/2024 - 17:13
Hi, I'm trying to write a STEP file and add a datum to a face. I use the following code:
Handle(XCAFDoc_DimTolTool) dimTolTool = XCAFDoc_DocumentTool::DimTolTool(doc->Main());
Handle(XCAFDoc_ShapeTool) shapeTool = XCAFDoc_DocumentTool::ShapeTool(doc->Main());
TDF_Label datumLabel = dimTolTool->AddDatum(
new TCollection_HAsciiString("DATUM-A"), new TCollection_HAsciiString(), new TCollection_HAsciiString());
Handle(XCAFDoc_Datum) datumAttribute;
datumLabel.FindAttribute(XCAFDoc_Datum::GetID(), datumAttribute);
TDF_Label faceLabel = shapeTool->AddShape(face);
TDF_LabelSequence shapes;
shapes.Append(faceLabel);
dimTolTool->SetDatum(shapes, datumLabel);
This indeed generates semantic DATUM
/DATUM_FEATURE
entities in the STEP file which is great! However I also want to add the visual representation of the datum to the file. With the triangle and datum letter and all. How can I do that? Are the StepRepr_*
classes used for that?
Fri, 12/13/2024 - 17:24
Hello. Adding a pre-tessellated representation is available for export to STP from XCAF.
It can be done by Handle(XCAFDimTolObjects_DatumObject) stored in XCAFDoc_Datum. Check XCAFDimTolObjects_DatumObject::SetPresentation.
The limitation: the presentation must be mesh. TopoDS_Face or Wire/Edge. No solids.
Best regards, Dmitrii
Fri, 12/13/2024 - 17:39
Thanks for the quick answer! I'm trying something like this:
But doesn't seem to change the resulting STEP file. What am I missing?
face
is a TopoDS_Face.Fri, 12/13/2024 - 17:43
Hello, I'm no sure about what missed. Looks fine. But only SetDatumTarget should be not the same as a presentation. Presentation must to be meshed (Should have triangulation). the schema must be AP242.
For now please check that XCAF was changed and label was added to the tree. You can use Inspector to validate XBF changes (tree changes).
Best regards, Dmitrii.
Fri, 12/13/2024 - 18:00
Thanks again, but I'm confused, sorry. What does the shape argument of
SetPresentation
do? What I want to achieve is to export the visual representation of the datum in the STEP file (for example attached visually to the face). I don't have such a visual representation - I'm asking for a built-in/standard one.PS Yes, I use AP242.
Fri, 12/13/2024 - 18:50
Creating of PMI as a shape is not a part of open source. I can only recommend to check FreeType and StdPrs_BRepTextBuilder to generate the text and then generate the contour according to the ISO.
Or you can purchase the PMIVis(Exchange) component: PMI Visualization Component | PMI software
Best regards, Dmitrii.
Fri, 12/13/2024 - 19:26
Many thanks!