diff --git a/src/Mod/Import/App/ExportOCAF2.cpp b/src/Mod/Import/App/ExportOCAF2.cpp index 6e954b6c79..1b4d1a04e3 100644 --- a/src/Mod/Import/App/ExportOCAF2.cpp +++ b/src/Mod/Import/App/ExportOCAF2.cpp @@ -390,7 +390,21 @@ TDF_Label ExportOCAF2::exportObject( const char* name ) { - App::DocumentObject* obj; + App::DocumentObject* obj = nullptr; + // keep a copy of the original object for naming purposes + App::DocumentObject* originalObj = parentObj; + + // check if this is a body and get its tip before getting the shape + if (parentObj && parentObj->isDerivedFrom(PartDesign::Body::getClassTypeId())) { + // if (obj->isDerivedFrom(PartDesign::Body::getClassTypeId())) { + auto* body = static_cast(parentObj); + App::DocumentObject* tip = body->Tip.getValue(); + if (tip) { + // obj = tip; + parentObj = tip; + } + } + auto shape = Part::Feature::getTopoShape( parentObj, (sub ? Part::ShapeOption::NoFlag : Part::ShapeOption::Transform), @@ -405,19 +419,6 @@ TDF_Label ExportOCAF2::exportObject( return {}; } - // keep a copy of the original object for naming purposes - App::DocumentObject* originalObj = obj; - - if (obj->isDerivedFrom(PartDesign::Body::getClassTypeId())) { - PartDesign::Body* body = static_cast(obj); - App::DocumentObject* tip = body->Tip.getValue(); - if (tip) { - // keep the shape from the body, but use the tip's colors - // by replacing obj with tip - obj = tip; - } - } - // sub may contain more than one hierarchy, e.g. Assembly container may use // getSubObjects to skip some hierarchy containing constraints and stuff // when exporting. We search for extra '.', and set it as prefix if found.