Missing Presentation PMI in STEP Export with STEPCAFControl_Writer

Hello everyone,I am working on exporting STEP files based on OCCT. After using STEPCAFControl_Writer to export PMI data, the exported file only contains semantic PMI but no presentation PMI. Why is this happening? Could it be due to incorrect parameter settings, missing code for exporting presentation PMI, or an incomplete OCCT module? Below is a code example:
//1.create doc
Handle(TDocStd_Document) doc;
Handle(XCAFApp_Application) app = XCAFApp_Application::GetApplication();
app->NewDocument("MDTV-XCAF", doc);
// 2. get tools
Handle(XCAFDoc_ShapeTool) shapeTool = XCAFDoc_DocumentTool::ShapeTool(doc->Main());
Handle(XCAFDoc_DimTolTool) dimTolTool = XCAFDoc_DocumentTool::DimTolTool(doc->Main());
//STEPControl_Writer aWriter;
// 3.create writer
STEPCAFControl_Writer aWriter;
//IFSelect_ReturnStatus status;
Standard_Boolean status;
TopoDS_Shape aShape;
Standard_Integer ix,ic = 0;
STEPControl_StepModelType aModel;
ExportProgStat& expStat = GetExportProgStat();
int ierr = STEPEXP_SUCCESS,nFalied = 0;

Interface_Static::SetCVal("write.step.schema", "AP242DIS");
Interface_Static::SetIVal("write.stepcaf.annot", 1);

//4. set
aWriter.SetColorMode(true);
aWriter.SetNameMode(true);
aWriter.SetLayerMode(true);
aWriter.SetDimTolMode(true); // 关键:启用PMI写入
aWriter.SetMaterialMode(true);
aWriter.SetNameMode(Standard_True);
aWriter.SetSHUOMode(Standard_True);
//5.add shape
Standard_Real x, y, z;
x = 100;
y = 50;
z = 30;
BRepPrimAPI_MakeBox box(x,y,z);
TopoDS_Shape aShape = box.Shape();
TDF_Label shapeLabel = shapeTool->AddShape(aShape, false);
// 6.add dimension
TDF_Label dimLabel = dimTolTool->AddDimension();
Handle(XCAFDimTolObjects_DimensionObject) dimObj;
Handle(XCAFDoc_Dimension) dimension;
if (dimLabel.FindAttribute(XCAFDoc_Dimension::GetID(), dimension)) {
if (!dimension.IsNull())
{
dimObj = dimension->GetObject();
Handle(TCollection_HAsciiString) sematicName = new TCollection_HAsciiString("linear");
dimObj->SetSemanticName(sematicName);
dimObj->SetType(XCAFDimTolObjects_DimensionType_Location_LinearDistance);
gp_Pnt pnt1(0, 0, 0);
gp_Pnt pnt2(100, 0, 0);
dimObj->SetPoint(pnt1);
dimObj->SetPoint(pnt2);
gp_Dir dimDir(1, 0, 0);
dimObj->SetPlane(gp_Ax2(gp_Pnt(0,0,0),gp_Dir(0,0,1)));
dimObj->SetDirection(dimDir);
dimObj->SetValue(100.0); // 尺寸值
dimension->SetObject(dimObj);
TDF_Label facelable1, facelable2;
GetYZParallelFacesLabels(doc, aShape, facelable1, facelable2);
dimTolTool->SetDimension(facelable1, facelable2, dimLabel);
status = aWriter.Transfer(doc, STEPControl_AsIs);

status = aWriter.Write(astrPath.ToCString());

Attachments: 
Dmitrii Pasukhin's picture

Hello, to export pre-tessellated presentation, you need to add presention.

The method to add the tessellated geometry to the objece: XCAFDoc_DimTolTool::SetGDTPresentations

The shapes can be faces with tessellation to edges(wires) with tessellated polygons.

Best regards, Dmitrii.

Kang Xian's picture

Thank you for your reply.
However, I would like to confirm whether this means that to solve my problem, I must explicitly create and set graphical representations for PMI, rather than relying solely on geometric data. Before exporting PMI information to a STEP file, I need to process the annotation information, such as dimensions, leader lines, and arrows, into tessellated geometry, and then set them as graphical representations via SetGDTPresentations.Do I understand correctly?
Additionally, I would like to know if I use OCCT 7.9.3 to export files in STEP242 format, can PMI-related information be fully exported using only open-source code and be completely read and displayed by other software, such as NX? If not, is purchasing a commercial module necessary? Looking forward to your reply.

Dmitrii Pasukhin's picture

OCCT's STEP Processor (graph interface) be able to write all the information into STEP file.

OCCT's XCAF representation of dimensions is following the ISO and compatible with all vendors.

OCCT do not have extra modules with STEP interface except kinematic (commercial). All STEP related parts are open-source. We are providing PMI-Vis module for the visualization of PMI, but storage and exchange is open source.

So, it means, if you fill up the XCAF containers, you data will be valid and exportable and importable by other vendors.

Best regards, Dmitrii.

Kang Xian's picture

Thanks a lot!