core: preserve body name in step file when exporting part that contains body with feature, fixes #24962

This commit is contained in:
chris
2025-11-21 14:35:03 -06:00
parent 9fc7b074b0
commit 2ef20d6030

View File

@@ -501,7 +501,10 @@ TDF_Label ExportOCAF2::exportObject(
baseShape.setShape(baseShape.getShape().Located(TopLoc_Location()));
label = aShapeTool->NewShape();
aShapeTool->SetShape(label, baseShape.getShape());
setupObject(label, linked, baseShape, prefix);
if (originalObj != linked) {
setupObject(label, linked, baseShape, prefix, nullptr, false);
}
setupObject(label, originalObj, baseShape, prefix, nullptr, false);
}
label = aShapeTool->AddComponent(parent, shape.getShape(), Standard_False);
@@ -536,6 +539,10 @@ TDF_Label ExportOCAF2::exportObject(
for (auto link : links) {
myObjects.emplace(link, label);
}
// also cache the body if it's different from obj (the tip)
if (originalObj != obj) {
myObjects.emplace(originalObj, label);
}
return label;
}
@@ -637,13 +644,23 @@ TDF_Label ExportOCAF2::exportObject(
myObjects.emplace(link, label);
}
if (originalObj != obj) {
myObjects.emplace(originalObj, label);
}
if (!parent.IsNull() && !links.empty()) {
linked = links.back();
}
else {
linked = obj;
}
setupObject(label, linked, baseShape, prefix);
// use the originalObj for naming if we changed obj to tip
App::DocumentObject* setupObj = (originalObj != obj) ? originalObj : linked;
setupObject(label, setupObj, baseShape, prefix);
#ifdef FC_DEBUG
Base::Console().warning("assembly name set to: %s\n", linked->Label.getValue());
#endif
if (!parent.IsNull()) {
// If we are a component, swap in the base shape but keep our location.