PDN: Automatically activate body if document has only 1
This commit is contained in:
@@ -63,15 +63,23 @@ PartDesign::Body *getBody(bool messageIfNot)
|
||||
{
|
||||
PartDesign::Body * activeBody = nullptr;
|
||||
Gui::MDIView *activeView = Gui::Application::Instance->activeView();
|
||||
bool singleBodyDocument = activeView->getAppDocument()->
|
||||
countObjectsOfType(PartDesign::Body::getClassTypeId()) == 1;
|
||||
|
||||
if (activeView) {
|
||||
if ( PartDesignGui::assureModernWorkflow ( activeView->getAppDocument() ) ) {
|
||||
activeBody = activeView->getActiveObject<PartDesign::Body*>(PDBODYKEY);
|
||||
|
||||
if (!activeBody && singleBodyDocument) {
|
||||
Gui::Command::doCommand( Gui::Command::Gui,
|
||||
"Gui.activeView().setActiveObject('pdbody',App.ActiveDocument.findObjects('PartDesign::Body')[0])");
|
||||
activeBody = activeView->getActiveObject<PartDesign::Body*>(PDBODYKEY);
|
||||
return activeBody;
|
||||
}
|
||||
if (!activeBody && messageIfNot) {
|
||||
QMessageBox::warning(Gui::getMainWindow(), QObject::tr("No active Body"),
|
||||
QObject::tr("In order to use PartDesign you need an active Body object in the document. "
|
||||
"Please make one active (double click) or create one. If you have a legacy document "
|
||||
"Please make one active (double click) or create one.\n\nIf you have a legacy document "
|
||||
"with PartDesign objects without Body, use the transfer function in "
|
||||
"PartDesign to put them into a Body."
|
||||
));
|
||||
|
||||
Reference in New Issue
Block a user