Fixed 0000663 - Naming scheme in Draft up/downgrade

This commit is contained in:
Yorik van Havre 2012-05-04 18:07:33 -03:00
parent c3f4871f15
commit 18c14eb1b0

View File

@ -2361,8 +2361,14 @@ class Upgrade(Modifier):
if (not curves) and (Draft.getType(self.sel[0]) == "Part"): if (not curves) and (Draft.getType(self.sel[0]) == "Part"):
msg(translate("draft", "Found 1 non-parametric objects: draftifying it\n")) msg(translate("draft", "Found 1 non-parametric objects: draftifying it\n"))
Draft.draftify(self.sel[0]) Draft.draftify(self.sel[0])
else:
msg(translate("draft", "No upgrade available for this object\n"))
self.doc.abortTransaction()
return
else: else:
msg(translate("draft", "Couldn't upgrade these objects\n")) msg(translate("draft", "Couldn't upgrade these objects\n"))
self.doc.abortTransaction()
return
elif wires and (not faces) and (not openwires): elif wires and (not faces) and (not openwires):
# we have only wires, no faces # we have only wires, no faces
@ -2385,15 +2391,12 @@ class Upgrade(Modifier):
msg(translate("draft", "One wire is not planar, upgrade not done\n")) msg(translate("draft", "One wire is not planar, upgrade not done\n"))
self.nodelete = True self.nodelete = True
for f in faces: for f in faces:
if not curves:
msg(translate("draft", "Found a closed wire: making a Draft wire\n"))
newob = Draft.makeWire(f.Wire,closed=True)
else:
# if there are curved segments, we do a non-parametric face # if there are curved segments, we do a non-parametric face
msg(translate("draft", "Found a closed wire with curves: making a face\n")) msg(translate("draft", "Found a closed wire: making a face\n"))
newob = self.doc.addObject("Part::Feature","Face") newob = self.doc.addObject("Part::Feature","Face")
newob.Shape = f newob.Shape = f
Draft.formatObject(newob,lastob) Draft.formatObject(newob,lastob)
newob.ViewObject.DisplayMode = "Flat Lines"
elif (len(openwires) == 1) and (not faces) and (not wires): elif (len(openwires) == 1) and (not faces) and (not wires):
# special case, we have only one open wire. We close it, unless it has only 1 edge!" # special case, we have only one open wire. We close it, unless it has only 1 edge!"
@ -2435,9 +2438,6 @@ class Upgrade(Modifier):
w = Part.Wire(nedges) w = Part.Wire(nedges)
if len(w.Edges) == len(edges): if len(w.Edges) == len(edges):
msg(translate("draft", "Found several edges: wiring them\n")) msg(translate("draft", "Found several edges: wiring them\n"))
if not curves:
newob = Draft.makeWire(w)
else:
newob = self.doc.addObject("Part::Feature","Wire") newob = self.doc.addObject("Part::Feature","Wire")
newob.Shape = w newob.Shape = w
Draft.formatObject(newob,lastob) Draft.formatObject(newob,lastob)
@ -2562,6 +2562,14 @@ class Downgrade(Modifier):
else: else:
# no faces: split wire into single edges # no faces: split wire into single edges
onlyedges = True
for ob in self.sel:
if ob.Shape.ShapeType != "Edge":
onlyedges = False
if onlyedges:
msg(translate("draft", "No more downgrade possible\n"))
self.doc.abortTransaction()
return
msg(translate("draft", "Found only wires: extracting their edges\n")) msg(translate("draft", "Found only wires: extracting their edges\n"))
for ob in self.sel: for ob in self.sel:
for e in edges: for e in edges: