From 13153b6260edd1a6553c9a557cc7c20f5ad64a18 Mon Sep 17 00:00:00 2001 From: Yorik van Havre Date: Mon, 19 Mar 2012 16:10:10 -0300 Subject: [PATCH] Fixed bug #584 in Draft Downgrade --- src/Mod/Draft/Draft.py | 16 +++++++++++++++- src/Mod/Draft/DraftTools.py | 7 +++++-- 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/src/Mod/Draft/Draft.py b/src/Mod/Draft/Draft.py index 6dba68709..8d306c25d 100644 --- a/src/Mod/Draft/Draft.py +++ b/src/Mod/Draft/Draft.py @@ -204,7 +204,21 @@ def shapify(obj): if not (obj.isDerivedFrom("Part::Feature")): return None if not "Shape" in obj.PropertiesList: return None shape = obj.Shape - name = getRealName(obj.Name) + if len(shape.Faces) == 1: + name = "Face" + elif len(shape.Solids) > 0: + name = "Solid" + elif len(shape.Faces) > 1: + name = "Shell" + elif len(shape.Wires) == 1: + name = "Wire" + elif len(shape.Edges) == 1: + if isinstance(shape.Edges[0].Curve,Part.Line): + name = "Line" + else: + name = "Circle" + else: + name = getRealName(obj.Name) FreeCAD.ActiveDocument.removeObject(obj.Name) newobj = FreeCAD.ActiveDocument.addObject("Part::Feature",name) newobj.Shape = shape diff --git a/src/Mod/Draft/DraftTools.py b/src/Mod/Draft/DraftTools.py index 649f8db2b..06f0222fd 100644 --- a/src/Mod/Draft/DraftTools.py +++ b/src/Mod/Draft/DraftTools.py @@ -2297,7 +2297,7 @@ class Upgrade(Modifier): newob = Draft.fuse(self.sel[0],self.sel[1]) self.nodelete = True - elif (len(self.sel) > 2) and (len(faces) > 10): + elif (len(self.sel) > 2) and (len(faces) > 6): # we have many separate faces: we try to make a shell sh = Part.makeShell(faces) newob = self.doc.addObject("Part::Feature","Shell") @@ -2316,6 +2316,7 @@ class Upgrade(Modifier): f = True u = fcgeo.concatenate(u) if not curves: + # several coplanar and non-curved faces: they can becoem a Draft wire msg(translate("draft", "Found several objects or faces: making a parametric face\n")) newob = Draft.makeWire(u.Wires[0],closed=True,face=f) Draft.formatObject(newob,lastob) @@ -2340,6 +2341,8 @@ class Upgrade(Modifier): if (not curves) and (Draft.getType(self.sel[0]) == "Part"): msg(translate("draft", "Found 1 non-parametric objects: draftifying it\n")) Draft.draftify(self.sel[0]) + else: + msg(translate("draft", "Couldn't upgrade these objects\n")) elif wires and (not faces) and (not openwires): # we have only wires, no faces @@ -2473,7 +2476,7 @@ class Downgrade(Modifier): self.doc.openTransaction("Downgrade") if (len(self.sel) == 1) and (Draft.getType(self.sel[0]) == "Block"): - # a block, we explode it + # we have a block, we explode it pl = self.sel[0].Placement newob = [] for ob in self.sel[0].Components: