Import: Export tip when body is selected (#24678)

This commit is contained in:
Chris
2025-10-20 10:59:18 -05:00
committed by GitHub
parent 31942728ce
commit ed229cd7df
3 changed files with 21 additions and 0 deletions

View File

@@ -1,5 +1,6 @@
set(Import_LIBS
Part
PartDesign
${OCC_OCAF_LIBRARIES}
${OCC_OCAF_DEBUG_LIBRARIES}
)

View File

@@ -45,6 +45,7 @@
#include <App/Part.h>
#include <Mod/Part/App/Interface.h>
#include <Mod/Part/App/PartFeature.h>
#include <Mod/PartDesign/App/Body.h>
#include "ExportOCAF.h"
#include "Tools.h"
@@ -172,6 +173,14 @@ int ExportOCAF::exportObject(App::DocumentObject* obj,
return_label = root_id;
}
if (obj->isDerivedFrom(PartDesign::Body::getClassTypeId())) {
PartDesign::Body* body = static_cast<PartDesign::Body*>(obj);
App::DocumentObject* tip = body->Tip.getValue();
if (tip && tip->isDerivedFrom<Part::Feature>()) {
// use the tip instead of the body for export
obj = tip;
}
}
if (obj->isDerivedFrom<Part::Feature>()) {
Part::Feature* part = static_cast<Part::Feature*>(obj);

View File

@@ -50,6 +50,7 @@
#include <Mod/Part/App/PartFeature.h>
#include <Mod/Part/App/Interface.h>
#include <Mod/Part/App/OCAF/ImportExportSettings.h>
#include <Mod/PartDesign/App/Body.h>
#include "ExportOCAF2.h"
@@ -392,6 +393,16 @@ TDF_Label ExportOCAF2::exportObject(App::DocumentObject* parentObj,
return {};
}
if (obj->isDerivedFrom(PartDesign::Body::getClassTypeId())) {
PartDesign::Body* body = static_cast<PartDesign::Body*>(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.