diff --git a/src/Gui/Tree.cpp b/src/Gui/Tree.cpp index 03ca7cb2f..2c5f0ea15 100644 --- a/src/Gui/Tree.cpp +++ b/src/Gui/Tree.cpp @@ -440,20 +440,39 @@ void TreeWidget::dropEvent(QDropEvent *event) ::getGroupOfObject(obj); if (par) { // allow an object to be in one group only - QString cmd = QString::fromAscii("App.getDocument(\"%1\").getObject(\"%2\").removeObject(" + QString cmd; + if (par->getTypeId().isDerivedFrom(App::DocumentObjectGroupPython::getClassTypeId())) { + // if this is a python group, call the method of its Proxy + cmd = QString::fromAscii("App.getDocument(\"%1\").getObject(\"%2\").Proxy.removeObject(" "App.getDocument(\"%1\").getObject(\"%3\"))") .arg(QString::fromAscii(doc->getName())) .arg(QString::fromAscii(par->getNameInDocument())) .arg(QString::fromAscii(obj->getNameInDocument())); + } else { + cmd = QString::fromAscii("App.getDocument(\"%1\").getObject(\"%2\").removeObject(" + "App.getDocument(\"%1\").getObject(\"%3\"))") + .arg(QString::fromAscii(doc->getName())) + .arg(QString::fromAscii(par->getNameInDocument())) + .arg(QString::fromAscii(obj->getNameInDocument())); + } Gui::Application::Instance->runPythonCode(cmd.toUtf8()); } // build Python command for execution - QString cmd = QString::fromAscii("App.getDocument(\"%1\").getObject(\"%2\").addObject(" + QString cmd; + if (grp->getTypeId().isDerivedFrom(App::DocumentObjectGroupPython::getClassTypeId())) { + cmd = QString::fromAscii("App.getDocument(\"%1\").getObject(\"%2\").Proxy.addObject(" "App.getDocument(\"%1\").getObject(\"%3\"))") .arg(QString::fromAscii(doc->getName())) .arg(QString::fromAscii(grp->getNameInDocument())) .arg(QString::fromAscii(obj->getNameInDocument())); + } else { + cmd = QString::fromAscii("App.getDocument(\"%1\").getObject(\"%2\").addObject(" + "App.getDocument(\"%1\").getObject(\"%3\"))") + .arg(QString::fromAscii(doc->getName())) + .arg(QString::fromAscii(grp->getNameInDocument())) + .arg(QString::fromAscii(obj->getNameInDocument())); + } Gui::Application::Instance->runPythonCode(cmd.toUtf8()); } gui->commitCommand();