Exporting STEP assembly - what am I doing wrong?

I have put together a minimal example of exporting a single shape to a step file and it works fine. However, when I try to export an assembly, the resulting step file is empty. See attached example. I'm using OCCT 7.2. Any idea of what I'm missing?

int main() {
    Handle(XCAFApp_Application) hApp = XCAFApp_Application::GetApplication();
    Handle(TDocStd_Document) aDoc;
    hApp->NewDocument(TCollection_ExtendedString("MDTV-CAF"), aDoc);
    TopoDS_Shape s1 = BRepPrimAPI_MakeBox(gp_Pnt(0, 0, 0), gp_Pnt(10, 30, 20));
    gp_Trsf t0;
    TopLoc_Location location0(t0);

    TDF_Label lab1 = XCAFDoc_DocumentTool::ShapeTool(aDoc->Main())->NewShape();
    XCAFDoc_DocumentTool::ShapeTool(aDoc->Main())->SetShape(lab1, s1);
    TDataStd_Name::Set(lab1, "Box1");
    // uncomment these lines and resulting step file will be empty
    // TDF_Label labelA = XCAFDoc_DocumentTool::ShapeTool(aDoc->Main())->NewShape();
    // TDataStd_Name::Set(labelA, "ASSEMBLY");
    // XCAFDoc_DocumentTool::ShapeTool(labelA)->AddComponent(labelA, lab1, location0);
    Interface_Static::SetCVal("write.step.schema", "AP214IS");

    STEPCAFControl_Writer writer;
    writer.Transfer(aDoc, STEPControl_AsIs);

	return 0;


Peter Lama's picture

Ah ha! Looks like I figured it out. With OCCT 7.2, the shape update is no longer performed automatically. Instead you have to call the method XCAFDoc_ShapeTool::UpdateAssemblies() introduced by this commit: http://git.dev.opencascade.org/gitweb/?p=occt.git;a=commitdiff;h=acc909a8934fb51c1ced8087663fc4f822b73d35