From 406c3ba42c4ee1cfa8f47759c577b5c69bd19fa8 Mon Sep 17 00:00:00 2001 From: marioalexis Date: Thu, 25 Sep 2025 10:40:47 -0300 Subject: [PATCH] PartDesign: Use `AllowCompound` user parameter along the workbench - fixes #23596 --- src/Mod/PartDesign/App/Body.cpp | 2 +- src/Mod/PartDesign/Gui/Command.cpp | 8 ++++++++ src/Mod/PartDesign/Gui/CommandBody.cpp | 7 +++++++ src/Mod/PartDesign/Gui/Utils.cpp | 11 +++++++++++ 4 files changed, 27 insertions(+), 1 deletion(-) diff --git a/src/Mod/PartDesign/App/Body.cpp b/src/Mod/PartDesign/App/Body.cpp index b46d0e545d..25cc873a71 100644 --- a/src/Mod/PartDesign/App/Body.cpp +++ b/src/Mod/PartDesign/App/Body.cpp @@ -42,7 +42,7 @@ PROPERTY_SOURCE(PartDesign::Body, Part::BodyBase) Body::Body() { - ADD_PROPERTY_TYPE(AllowCompound, (false), "Experimental", App::Prop_None, "Allow multiple solids in Body (experimental)"); + ADD_PROPERTY_TYPE(AllowCompound, (true), "Experimental", App::Prop_None, "Allow multiple solids in Body (experimental)"); _GroupTouched.setStatus(App::Property::Output, true); } diff --git a/src/Mod/PartDesign/Gui/Command.cpp b/src/Mod/PartDesign/Gui/Command.cpp index f88fc1aa12..c7d06181ca 100644 --- a/src/Mod/PartDesign/Gui/Command.cpp +++ b/src/Mod/PartDesign/Gui/Command.cpp @@ -458,11 +458,19 @@ void CmdPartDesignClone::activated(int iMsg) auto bodyObj = obj->getDocument()->getObject(bodyName.c_str()); auto cloneObj = obj->getDocument()->getObject(cloneName.c_str()); + Base::Reference hGrp = App::GetApplication() + .GetUserParameter() + .GetGroup("BaseApp/Preferences/Mod/PartDesign"); + + bool allowCompound = hGrp->GetBool("AllowCompoundDefault", true); + // In the first step set the group link and tip of the body Gui::cmdAppObject(bodyObj, std::stringstream() << "Group = [" << getObjectCmd(cloneObj) << "]"); Gui::cmdAppObject(bodyObj, std::stringstream() << "Tip = " << getObjectCmd(cloneObj)); + Gui::cmdAppObject(bodyObj, std::stringstream() + << "AllowCompound = " << (allowCompound ? "True" : "False")); // In the second step set the link of the base feature Gui::cmdAppObject(cloneObj, std::stringstream() diff --git a/src/Mod/PartDesign/Gui/CommandBody.cpp b/src/Mod/PartDesign/Gui/CommandBody.cpp index c8ecfed725..a922740640 100644 --- a/src/Mod/PartDesign/Gui/CommandBody.cpp +++ b/src/Mod/PartDesign/Gui/CommandBody.cpp @@ -471,8 +471,15 @@ void CmdPartDesignMigrate::activated(int iMsg) std::string bodyName = getUniqueObjectName ( std::string ( chainIt->back()->getNameInDocument() ).append ( "Body" ).c_str () ) ; + Base::Reference hGrp = App::GetApplication() + .GetUserParameter() + .GetGroup("BaseApp/Preferences/Mod/PartDesign"); + + bool allowCompound = hGrp->GetBool("AllowCompoundDefault", true); + // Create a body for the chain doCommand ( Doc,"App.activeDocument().addObject('PartDesign::Body','%s')", bodyName.c_str () ); + doCommand ( Doc,"App.ActiveDocument.getObject('%s').AllowCompound = %s", bodyName.c_str(), allowCompound ? "True" : "False"); doCommand ( Doc,"App.activeDocument().%s.addObject(App.ActiveDocument.%s)", actPart->getNameInDocument (), bodyName.c_str () ); if (base) { diff --git a/src/Mod/PartDesign/Gui/Utils.cpp b/src/Mod/PartDesign/Gui/Utils.cpp index c395057800..ac217d45e6 100644 --- a/src/Mod/PartDesign/Gui/Utils.cpp +++ b/src/Mod/PartDesign/Gui/Utils.cpp @@ -189,11 +189,22 @@ void needActiveBodyError() PartDesign::Body * makeBody(App::Document *doc) { + Base::Reference hGrp = App::GetApplication() + .GetUserParameter() + .GetGroup("BaseApp/Preferences/Mod/PartDesign"); + + bool allowCompound = hGrp->GetBool("AllowCompoundDefault", true); + // This is intended as a convenience when starting a new document. auto bodyName( doc->getUniqueObjectName("Body") ); Gui::Command::doCommand( Gui::Command::Doc, "App.getDocument('%s').addObject('PartDesign::Body','%s')", doc->getName(), bodyName.c_str() ); + Gui::Command::doCommand( Gui::Command::Doc, + "App.getDocument('%s').getObject('%s').AllowCompound = %s", + doc->getName(), bodyName.c_str(), allowCompound ? "True" : "False" ); + + auto body = dynamic_cast(doc->getObject(bodyName.c_str())); if(body) makeBodyActive(body, doc);