PartDesign: Use AllowCompound user parameter along the workbench - fixes #23596

This commit is contained in:
marioalexis
2025-09-25 10:40:47 -03:00
committed by Chris Hennes
parent 68b754effd
commit 406c3ba42c
4 changed files with 27 additions and 1 deletions

View File

@@ -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);
}

View File

@@ -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<ParameterGrp> 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()

View File

@@ -471,8 +471,15 @@ void CmdPartDesignMigrate::activated(int iMsg)
std::string bodyName = getUniqueObjectName (
std::string ( chainIt->back()->getNameInDocument() ).append ( "Body" ).c_str () ) ;
Base::Reference<ParameterGrp> 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) {

View File

@@ -189,11 +189,22 @@ void needActiveBodyError()
PartDesign::Body * makeBody(App::Document *doc)
{
Base::Reference<ParameterGrp> 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<PartDesign::Body*>(doc->getObject(bodyName.c_str()));
if(body)
makeBodyActive(body, doc);