Merge pull request #14608 from Ondsel-Development/asm_del_obj
Assembly: Makes sure deleting assembly deletes the joints and views
This commit is contained in:
@@ -1675,14 +1675,14 @@ void AssemblyObject::swapJCS(App::DocumentObject* joint)
|
||||
}
|
||||
|
||||
bool AssemblyObject::isEdgeType(App::DocumentObject* obj,
|
||||
const char* elName,
|
||||
std::string& elName,
|
||||
GeomAbs_CurveType type)
|
||||
{
|
||||
PartApp::Feature* base = static_cast<PartApp::Feature*>(obj);
|
||||
const PartApp::TopoShape& TopShape = base->Shape.getShape();
|
||||
|
||||
// Check for valid face types
|
||||
TopoDS_Edge edge = TopoDS::Edge(TopShape.getSubShape(elName));
|
||||
TopoDS_Edge edge = TopoDS::Edge(TopShape.getSubShape(elName.c_str()));
|
||||
BRepAdaptor_Curve sf(edge);
|
||||
|
||||
if (sf.GetType() == type) {
|
||||
@@ -1693,16 +1693,16 @@ bool AssemblyObject::isEdgeType(App::DocumentObject* obj,
|
||||
}
|
||||
|
||||
bool AssemblyObject::isFaceType(App::DocumentObject* obj,
|
||||
const char* elName,
|
||||
std::string& elName,
|
||||
GeomAbs_SurfaceType type)
|
||||
{
|
||||
auto base = static_cast<PartApp::Feature*>(obj);
|
||||
PartApp::TopoShape TopShape = base->Shape.getShape();
|
||||
|
||||
// Check for valid face types
|
||||
TopoDS_Face face = TopoDS::Face(TopShape.getSubShape(elName));
|
||||
TopoDS_Face face = TopoDS::Face(TopShape.getSubShape(elName.c_str()));
|
||||
BRepAdaptor_Surface sf(face);
|
||||
// GeomAbs_Plane GeomAbs_Cylinder GeomAbs_Cone GeomAbs_Sphere GeomAbs_Thorus
|
||||
|
||||
if (sf.GetType() == type) {
|
||||
return true;
|
||||
}
|
||||
@@ -1749,8 +1749,8 @@ DistanceType AssemblyObject::getDistanceType(App::DocumentObject* joint)
|
||||
{
|
||||
std::string type1 = getElementTypeFromProp(joint, "Element1");
|
||||
std::string type2 = getElementTypeFromProp(joint, "Element2");
|
||||
const char* elt1 = getElementFromProp(joint, "Element1");
|
||||
const char* elt2 = getElementFromProp(joint, "Element2");
|
||||
std::string elt1 = getElementFromProp(joint, "Element1");
|
||||
std::string elt2 = getElementFromProp(joint, "Element2");
|
||||
auto* obj1 = getLinkedObjFromNameProp(joint, "Object1", "Part1");
|
||||
auto* obj2 = getLinkedObjFromNameProp(joint, "Object2", "Part2");
|
||||
|
||||
|
||||
@@ -237,8 +237,8 @@ public:
|
||||
|
||||
static void swapJCS(App::DocumentObject* joint);
|
||||
|
||||
static bool isEdgeType(App::DocumentObject* obj, const char* elName, GeomAbs_CurveType type);
|
||||
static bool isFaceType(App::DocumentObject* obj, const char* elName, GeomAbs_SurfaceType type);
|
||||
static bool isEdgeType(App::DocumentObject* obj, std::string& elName, GeomAbs_CurveType type);
|
||||
static bool isFaceType(App::DocumentObject* obj, std::string& elName, GeomAbs_SurfaceType type);
|
||||
static double getFaceRadius(App::DocumentObject* obj, const char* elName);
|
||||
static double getEdgeRadius(App::DocumentObject* obj, const char* elName);
|
||||
|
||||
|
||||
@@ -210,6 +210,11 @@ class ViewProviderExplodedView:
|
||||
|
||||
return True
|
||||
|
||||
def onDelete(self, vobj, subelements):
|
||||
for obj in self.claimChildren():
|
||||
obj.Document.removeObject(obj.Name)
|
||||
return True
|
||||
|
||||
|
||||
######### Exploded View Move #########
|
||||
ExplodedViewStepTypes = [
|
||||
|
||||
@@ -55,6 +55,7 @@
|
||||
#include <Mod/Assembly/App/AssemblyObject.h>
|
||||
#include <Mod/Assembly/App/AssemblyUtils.h>
|
||||
#include <Mod/Assembly/App/JointGroup.h>
|
||||
#include <Mod/Assembly/App/ViewGroup.h>
|
||||
#include <Mod/PartDesign/App/Body.h>
|
||||
|
||||
#include "ViewProviderAssembly.h"
|
||||
@@ -887,10 +888,20 @@ void ViewProviderAssembly::onSelectionChanged(const Gui::SelectionChanges& msg)
|
||||
|
||||
bool ViewProviderAssembly::onDelete(const std::vector<std::string>& subNames)
|
||||
{
|
||||
// Delete the joingroup when assembly is deleted
|
||||
// Delete the assembly goups when assembly is deleted
|
||||
for (auto obj : getObject()->getOutList()) {
|
||||
if (obj->getTypeId() == Assembly::JointGroup::getClassTypeId()) {
|
||||
obj->getDocument()->removeObject(obj->getNameInDocument());
|
||||
if (obj->getTypeId() == Assembly::JointGroup::getClassTypeId()
|
||||
|| obj->getTypeId() == Assembly::ViewGroup::getClassTypeId()
|
||||
/* || obj->getTypeId() == Assembly::BomGroup::getClassTypeId()*/) {
|
||||
|
||||
// Delete the group content first.
|
||||
Gui::Command::doCommand(Gui::Command::Doc,
|
||||
"doc = App.getDocument(\"%s\")\n"
|
||||
"objName = \"%s\"\n"
|
||||
"doc.getObject(objName).removeObjectsFromDocument()\n"
|
||||
"doc.removeObject(objName)\n",
|
||||
obj->getDocument()->getName(),
|
||||
obj->getNameInDocument());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user