diff --git a/src/Mod/PartDesign/App/Body.cpp b/src/Mod/PartDesign/App/Body.cpp index 861eadc44..3e4212e96 100644 --- a/src/Mod/PartDesign/App/Body.cpp +++ b/src/Mod/PartDesign/App/Body.cpp @@ -62,7 +62,7 @@ Body::Body() { // Note: The following code will catch Python Document::removeObject() modifications. If the object removed is // a member of the Body::Group, then it will be automatically removed from the Group property which triggers the // following two methods -// But since we require the Python user to call both Document::addObject() and Body::addFeature(), we should +// But since we require the Python user to call both Document::addObject() and Body::addObject(), we should // also require calling both Document::removeObject and Body::removeFeature() in order to be consistent void Body::onBeforeChange(const App::Property *prop) { diff --git a/src/Mod/PartDesign/App/Body.h b/src/Mod/PartDesign/App/Body.h index c56ddcb4a..a73ab7003 100644 --- a/src/Mod/PartDesign/App/Body.h +++ b/src/Mod/PartDesign/App/Body.h @@ -79,7 +79,7 @@ public: * and into the begin if where is InsertAfter. * @param after if true insert the feature after the target. Default is false. * - * @note the methode doesn't modifies the Tip unlike addFeature() + * @note the methode doesn't modifies the Tip unlike addObject() */ void insertObject(App::DocumentObject* feature, App::DocumentObject* target, bool after=false); diff --git a/src/Mod/PartDesign/App/BodyPy.xml b/src/Mod/PartDesign/App/BodyPy.xml index 9569b1acc..b4889eb42 100644 --- a/src/Mod/PartDesign/App/BodyPy.xml +++ b/src/Mod/PartDesign/App/BodyPy.xml @@ -13,14 +13,9 @@ PartDesign body class - + - addFeature(feat) - Add the given feature after the current Tip feature - - - - - insertFeatureAfter(feature, target, after=False) + insertObject(feature, target, after=False) Insert the feature into the body after the given feature. @param feature The feature to insert into the body @@ -29,19 +24,9 @@ and into the begin if where is InsertAfter. @param after if true insert the feature after the target. Default is false. - @note the methode doesn't modifies the Tip unlike addFeature() + @note the methode doesn't modifies the Tip unlike addObject() - - - removeFeature(feat) - Remove the given feature from the Body - - - - - Delets all the objects linked to the model. - - diff --git a/src/Mod/PartDesign/App/BodyPyImp.cpp b/src/Mod/PartDesign/App/BodyPyImp.cpp index dec68ce45..1650bb8fd 100644 --- a/src/Mod/PartDesign/App/BodyPyImp.cpp +++ b/src/Mod/PartDesign/App/BodyPyImp.cpp @@ -52,32 +52,7 @@ int BodyPy::setCustomAttributes(const char* /*attr*/, PyObject* /*obj*/) return 0; } -PyObject* BodyPy::addFeature(PyObject *args) -{ - PyObject* featurePy; - if (!PyArg_ParseTuple(args, "O!", &(App::DocumentObjectPy::Type), &featurePy)) - return 0; - - App::DocumentObject* feature = static_cast(featurePy)->getDocumentObjectPtr(); - - if (!Body::isAllowed(feature)) { - PyErr_SetString(PyExc_SystemError, "Only PartDesign features, datum features and sketches can be inserted into a Body"); - return 0; - } - - Body* body = this->getBodyPtr(); - - try { - body->addObject(feature); - } catch (Base::Exception& e) { - PyErr_SetString(PyExc_SystemError, e.what()); - return 0; - } - - Py_Return; -} - -PyObject* BodyPy::insertFeature(PyObject *args) +PyObject* BodyPy::insertObject(PyObject *args) { PyObject* featurePy; PyObject* targetPy; @@ -115,32 +90,3 @@ PyObject* BodyPy::insertFeature(PyObject *args) Py_Return; } - -PyObject* BodyPy::removeFeature(PyObject *args) -{ - PyObject* featurePy; - if (!PyArg_ParseTuple(args, "O!", &(App::DocumentObjectPy::Type), &featurePy)) - return 0; - - App::DocumentObject* feature = static_cast(featurePy)->getDocumentObjectPtr(); - Body* body = this->getBodyPtr(); - - try { - body->removeObject(feature); - } catch (Base::Exception& e) { - PyErr_SetString(PyExc_SystemError, e.what()); - return 0; - } - - Py_Return; -} - -PyObject* BodyPy::removeModelFromDocument(PyObject *args) -{ - if (!PyArg_ParseTuple(args, "")) - return 0; - - getBodyPtr()->removeObjectsFromDocument(); - Py_Return; -} - diff --git a/src/Mod/PartDesign/FeatureHole/TaskHole.py b/src/Mod/PartDesign/FeatureHole/TaskHole.py index 1f5a8c065..db05f339b 100644 --- a/src/Mod/PartDesign/FeatureHole/TaskHole.py +++ b/src/Mod/PartDesign/FeatureHole/TaskHole.py @@ -54,18 +54,18 @@ class TaskHole: sketch = groove.Sketch plane = sketch.Support[0] axis = plane.References[0][0] - body.removeFeature(self.feature) + body.removeObject(self.feature) document.removeObject(self.feature.Name) - body.removeFeature(groove) + body.removeObject(groove) document.removeObject(groove.Name) - body.removeFeature(sketch) + body.removeObject(sketch) try: document.removeObject(sketch.Name) except: pass # This always throws an exception: "Sketch support has been deleted" from SketchObject::execute() - body.removeFeature(plane) + body.removeObject(plane) document.removeObject(plane.Name) - body.removeFeature(axis) + body.removeObject(axis) document.removeObject(axis.Name) FreeCADGui.ActiveDocument.resetEdit() FreeCADGui.Control.closeDialog(self) diff --git a/src/Mod/PartDesign/Gui/Command.cpp b/src/Mod/PartDesign/Gui/Command.cpp index 9afa17988..0c5e398cf 100644 --- a/src/Mod/PartDesign/Gui/Command.cpp +++ b/src/Mod/PartDesign/Gui/Command.cpp @@ -125,7 +125,7 @@ void UnifiedDatumCommand(Gui::Command &cmd, Base::Type type, std::string name) } } if (pcActiveBody) { - cmd.doCommand(Gui::Command::Doc,"App.activeDocument().%s.addFeature(App.activeDocument().%s)", + cmd.doCommand(Gui::Command::Doc,"App.activeDocument().%s.addObject(App.activeDocument().%s)", pcActiveBody->getNameInDocument(), FeatName.c_str()); } cmd.doCommand(Gui::Command::Doc,"App.activeDocument().recompute()"); // recompute the feature based on its references @@ -278,7 +278,7 @@ void CmdPartDesignShapeBinder::activated(int iMsg) doCommand(Gui::Command::Doc,"App.activeDocument().%s.Support = %s", FeatName.c_str(), support.getPyReprString().c_str()); } - doCommand(Gui::Command::Doc,"App.activeDocument().%s.addFeature(App.activeDocument().%s)", + doCommand(Gui::Command::Doc,"App.activeDocument().%s.addObject(App.activeDocument().%s)", pcActiveBody->getNameInDocument(), FeatName.c_str()); doCommand(Gui::Command::Doc,"App.activeDocument().recompute()"); // recompute the feature based on its references doCommand(Gui::Command::Gui,"Gui.activeDocument().setEdit('%s')",FeatName.c_str()); @@ -429,7 +429,7 @@ void CmdPartDesignNewSketch::activated(int iMsg) doCommand(Doc,"App.activeDocument().addObject('Sketcher::SketchObject','%s')",FeatName.c_str()); doCommand(Doc,"App.activeDocument().%s.Support = %s",FeatName.c_str(),supportString.c_str()); doCommand(Doc,"App.activeDocument().%s.MapMode = '%s'",FeatName.c_str(),Attacher::AttachEngine::getModeName(Attacher::mmFlatFace).c_str()); - doCommand(Doc,"App.activeDocument().%s.addFeature(App.activeDocument().%s)", + doCommand(Doc,"App.activeDocument().%s.addObject(App.activeDocument().%s)", pcActiveBody->getNameInDocument(), FeatName.c_str()); doCommand(Gui,"App.activeDocument().recompute()"); // recompute the sketch placement based on its support //doCommand(Gui,"Gui.activeDocument().activeView().setCamera('%s')",cam.c_str()); @@ -521,7 +521,7 @@ void CmdPartDesignNewSketch::activated(int iMsg) Gui::Command::doCommand(Doc,"App.activeDocument().%s.Support = %s",FeatName.c_str(),supportString.c_str()); Gui::Command::doCommand(Doc,"App.activeDocument().%s.MapMode = '%s'",FeatName.c_str(),Attacher::AttachEngine::getModeName(Attacher::mmFlatFace).c_str()); Gui::Command::updateActive(); // Make sure the Support's Placement property is updated - Gui::Command::doCommand(Doc,"App.activeDocument().%s.addFeature(App.activeDocument().%s)", + Gui::Command::doCommand(Doc,"App.activeDocument().%s.addObject(App.activeDocument().%s)", pcActiveBody->getNameInDocument(), FeatName.c_str()); //doCommand(Gui,"Gui.activeDocument().activeView().setCamera('%s')",cam.c_str()); Gui::Command::doCommand(Gui,"Gui.activeDocument().setEdit('%s')",FeatName.c_str()); @@ -584,13 +584,13 @@ void finishFeature(const Gui::Command* cmd, const std::string& FeatName, App::DocumentObject* lastSolidFeature = pcActiveBody->Tip.getValue(); if (!prevSolidFeature || prevSolidFeature == lastSolidFeature) { // If the previous feature not given or is the Tip add Feature after it. - cmd->doCommand(cmd->Doc,"App.activeDocument().%s.addFeature(App.activeDocument().%s)", + cmd->doCommand(cmd->Doc,"App.activeDocument().%s.addObject(App.activeDocument().%s)", pcActiveBody->getNameInDocument(), FeatName.c_str()); prevSolidFeature = lastSolidFeature; } else { // Insert the feature into the body after the given one. cmd->doCommand(cmd->Doc, - "App.activeDocument().%s.insertFeature(App.activeDocument().%s, App.activeDocument().%s, True)", + "App.activeDocument().%s.insertObject(App.activeDocument().%s, App.activeDocument().%s, True)", pcActiveBody->getNameInDocument(), FeatName.c_str(), prevSolidFeature->getNameInDocument()); } } @@ -1855,7 +1855,7 @@ void CmdPartDesignMultiTransform::activated(int iMsg) // Remove the Transformed feature from the Body if(pcActiveBody) - doCommand(Doc, "App.activeDocument().%s.removeFeature(App.activeDocument().%s)", + doCommand(Doc, "App.activeDocument().%s.removeObject(App.activeDocument().%s)", pcActiveBody->getNameInDocument(), trFeat->getNameInDocument()); // Create a MultiTransform feature and move the Transformed feature inside it diff --git a/src/Mod/PartDesign/Gui/CommandBody.cpp b/src/Mod/PartDesign/Gui/CommandBody.cpp index 0867cebf3..cfc4c2347 100644 --- a/src/Mod/PartDesign/Gui/CommandBody.cpp +++ b/src/Mod/PartDesign/Gui/CommandBody.cpp @@ -401,7 +401,7 @@ void CmdPartDesignMigrate::activated(int iMsg) PartDesign::ProfileBased *sketchBased = static_cast ( feature ); Part::Part2DObject *sketch = sketchBased->getVerifiedSketch( /*silent =*/ true); if ( sketch ) { - doCommand ( Doc,"App.activeDocument().%s.addFeature(App.activeDocument().%s)", + doCommand ( Doc,"App.activeDocument().%s.addObject(App.activeDocument().%s)", bodyName.c_str (), sketch->getNameInDocument() ); if ( sketch->isDerivedFrom ( Sketcher::SketchObject::getClassTypeId() ) ) { @@ -419,7 +419,7 @@ void CmdPartDesignMigrate::activated(int iMsg) } } } - doCommand ( Doc,"App.activeDocument().%s.addFeature(App.activeDocument().%s)", + doCommand ( Doc,"App.activeDocument().%s.addObject(App.activeDocument().%s)", bodyName.c_str (), feature->getNameInDocument() ); PartDesignGui::relinkToBody ( feature ); @@ -552,7 +552,7 @@ void CmdPartDesignDuplicateSelection::activated(int iMsg) for (auto feature : newFeatures) { if (PartDesign::Body::isAllowed(feature)) { - doCommand(Doc,"App.activeDocument().%s.addFeature(App.activeDocument().%s)", + doCommand(Doc,"App.activeDocument().%s.addObject(App.activeDocument().%s)", pcActiveBody->getNameInDocument(), feature->getNameInDocument()); doCommand(Gui,"Gui.activeDocument().hide(\"%s\")", feature->getNameInDocument()); } @@ -658,14 +658,14 @@ void CmdPartDesignMoveFeature::activated(int iMsg) // Remove from the source body if the feature belonged to a body if (source) { featureWasTip = (source->Tip.getValue() == feat); - doCommand(Doc,"App.activeDocument().%s.removeFeature(App.activeDocument().%s)", + doCommand(Doc,"App.activeDocument().%s.removeObject(App.activeDocument().%s)", source->getNameInDocument(), (feat)->getNameInDocument()); } App::DocumentObject* targetOldTip = target->Tip.getValue(); // Add to target body (always at the Tip) - doCommand(Doc,"App.activeDocument().%s.addFeature(App.activeDocument().%s)", + doCommand(Doc,"App.activeDocument().%s.addObject(App.activeDocument().%s)", target->getNameInDocument(), (feat)->getNameInDocument()); // Recompute to update the shape doCommand(Gui,"App.activeDocument().recompute()"); @@ -798,9 +798,9 @@ void CmdPartDesignMoveFeatureInTree::activated(int iMsg) // Remove and re-insert the feature to/from the Body // TODO if tip was moved the new position of tip is quite undetermined (2015-08-07, Fat-Zer) // TODO warn the user if we are moving an object to some place before the object's link (2015-08-07, Fat-Zer) - doCommand ( Doc,"App.activeDocument().%s.removeFeature(App.activeDocument().%s)", + doCommand ( Doc,"App.activeDocument().%s.removeObject(App.activeDocument().%s)", body->getNameInDocument(), feat->getNameInDocument() ); - doCommand ( Doc, "App.activeDocument().%s.insertFeature(App.activeDocument().%s, %s, True)", + doCommand ( Doc, "App.activeDocument().%s.insertObject(App.activeDocument().%s, %s, True)", body->getNameInDocument(), feat->getNameInDocument(), targetStr.c_str () ); } diff --git a/src/Mod/PartDesign/Gui/CommandPrimitive.cpp b/src/Mod/PartDesign/Gui/CommandPrimitive.cpp index 9c21237f2..feccacc70 100644 --- a/src/Mod/PartDesign/Gui/CommandPrimitive.cpp +++ b/src/Mod/PartDesign/Gui/CommandPrimitive.cpp @@ -133,7 +133,7 @@ void CmdPrimtiveCompAdditive::activated(int iMsg) } - Gui::Command::doCommand(Doc,"App.ActiveDocument.%s.addFeature(App.activeDocument().%s)" + Gui::Command::doCommand(Doc,"App.ActiveDocument.%s.addObject(App.activeDocument().%s)" ,pcActiveBody->getNameInDocument(), FeatName.c_str()); Gui::Command::updateActive(); @@ -322,7 +322,7 @@ void CmdPrimtiveCompSubtractive::activated(int iMsg) FeatName.c_str()); } - Gui::Command::doCommand(Doc,"App.ActiveDocument.%s.addFeature(App.activeDocument().%s)" + Gui::Command::doCommand(Doc,"App.ActiveDocument.%s.addObject(App.activeDocument().%s)" ,pcActiveBody->getNameInDocument(), FeatName.c_str()); Gui::Command::updateActive(); diff --git a/src/Mod/PartDesign/Gui/Utils.cpp b/src/Mod/PartDesign/Gui/Utils.cpp index 09d62ad41..4e3740322 100644 --- a/src/Mod/PartDesign/Gui/Utils.cpp +++ b/src/Mod/PartDesign/Gui/Utils.cpp @@ -221,7 +221,7 @@ void fixSketchSupport (Sketcher::SketchObject* sketch) Gui::Command::doCommand(Gui::Command::Doc,"App.activeDocument().%s.superPlacement.Base.z = %f", Datum.c_str(), offset); Gui::Command::doCommand(Gui::Command::Doc, - "App.activeDocument().%s.insertFeature(App.activeDocument().%s, App.activeDocument().%s)", + "App.activeDocument().%s.insertObject(App.activeDocument().%s, App.activeDocument().%s)", body->getNameInDocument(), Datum.c_str(), sketch->getNameInDocument()); Gui::Command::doCommand(Gui::Command::Doc, "App.activeDocument().%s.Support = (App.activeDocument().%s,[''])", diff --git a/src/Mod/PartDesign/Gui/ViewProviderBody.cpp b/src/Mod/PartDesign/Gui/ViewProviderBody.cpp index 4ec62cbce..ee278b840 100644 --- a/src/Mod/PartDesign/Gui/ViewProviderBody.cpp +++ b/src/Mod/PartDesign/Gui/ViewProviderBody.cpp @@ -283,7 +283,7 @@ std::vector ViewProviderBody::claimChildren3D(void)const bool ViewProviderBody::onDelete ( const std::vector &) { // TODO May be do it conditionally? (2015-09-05, Fat-Zer) Gui::Command::doCommand(Gui::Command::Doc, - "App.getDocument(\"%s\").getObject(\"%s\").removeGroupFromDocument()" + "App.getDocument(\"%s\").getObject(\"%s\").removeObjectsFromDocument()" ,getObject()->getDocument()->getName(), getObject()->getNameInDocument()); return true; } diff --git a/src/Mod/PartDesign/Gui/Workbench.cpp b/src/Mod/PartDesign/Gui/Workbench.cpp index c413ba555..d051d0bc0 100644 --- a/src/Mod/PartDesign/Gui/Workbench.cpp +++ b/src/Mod/PartDesign/Gui/Workbench.cpp @@ -151,7 +151,7 @@ void Workbench::slotNewObject(const App::DocumentObject& obj) if ((obj.getDocument() == ActiveAppDoc) && (ActivePartObject != NULL)) { // Add the new object to the active Body // Note: Will this break Undo? But how else can we catch Edit->Duplicate selection? - Gui::Command::doCommand(Gui::Command::Doc,"App.activeDocument().%s.addFeature(App.activeDocument().%s)", + Gui::Command::doCommand(Gui::Command::Doc,"App.activeDocument().%s.addObject(App.activeDocument().%s)", ActivePartObject->getNameInDocument(), obj.getNameInDocument()); } } diff --git a/src/Mod/PartDesign/TestPartDesignGui.py b/src/Mod/PartDesign/TestPartDesignGui.py index ab158b91e..cac04b685 100644 --- a/src/Mod/PartDesign/TestPartDesignGui.py +++ b/src/Mod/PartDesign/TestPartDesignGui.py @@ -72,14 +72,14 @@ class PartDesignGuiTestCases(unittest.TestCase): self.BoxObj.Length=10.0 self.BoxObj.Width=10.0 self.BoxObj.Height=10.0 - self.BodySource.addFeature(self.BoxObj) + self.BodySource.addObject(self.BoxObj) App.ActiveDocument.recompute() self.Sketch = self.Doc.addObject('Sketcher::SketchObject','Sketch') self.Sketch.Support = (self.BoxObj, ('Face3',)) self.Sketch.MapMode = 'FlatFace' - self.BodySource.addFeature(self.Sketch) + self.BodySource.addObject(self.Sketch) geoList = [] geoList.append(Part.LineSegment(App.Vector(2.0,8.0,0),App.Vector(8.0,8.0,0))) @@ -108,7 +108,7 @@ class PartDesignGuiTestCases(unittest.TestCase): self.Pad.Midplane = 0 self.Pad.Offset = 0.000000 - self.BodySource.addFeature(self.Pad) + self.BodySource.addObject(self.Pad) self.Doc.recompute() Gui.SendMsgToActiveView("ViewFit") @@ -131,7 +131,7 @@ class PartDesignGuiTestCases(unittest.TestCase): self.Sketch = self.Doc.addObject('Sketcher::SketchObject','Sketch') self.Sketch.Support = (self.Doc.XY_Plane, ['']) self.Sketch.MapMode = 'FlatFace' - self.BodySource.addFeature(self.Sketch) + self.BodySource.addObject(self.Sketch) geoList = [] geoList.append(Part.LineSegment(App.Vector(-10.000000,10.000000,0),App.Vector(10.000000,10.000000,0))) @@ -160,7 +160,7 @@ class PartDesignGuiTestCases(unittest.TestCase): self.Pad.Midplane = 0 self.Pad.Offset = 0.000000 - self.BodySource.addFeature(self.Pad) + self.BodySource.addObject(self.Pad) self.Doc.recompute() Gui.SendMsgToActiveView("ViewFit")