Skip to content

Commit

Permalink
Draft: more consistent offset result - fixes #2027
Browse files Browse the repository at this point in the history
  • Loading branch information
yorikvanhavre committed Dec 3, 2015
1 parent 3414ec8 commit cf1c022
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions src/Mod/Draft/Draft.py
Expand Up @@ -1441,6 +1441,7 @@ def offset(obj,delta,copy=False,bind=False,sym=False,occ=False):
sides, the total width being the given delta length.'''
import Part, DraftGeomUtils
newwire = None
delete = None

if getType(obj) in ["Sketch","Part"]:
copy = True
Expand Down Expand Up @@ -1503,6 +1504,8 @@ def getRadius(obj,delta):
newobj = FreeCAD.ActiveDocument.addObject("Part::Feature","Offset")
newobj.Shape = DraftGeomUtils.offsetWire(obj.Shape,delta,occ=True)
formatObject(newobj,obj)
if not copy:
delete = obj.Name
elif bind:
if not DraftGeomUtils.isReallyClosed(obj.Shape):
if sym:
Expand All @@ -1515,9 +1518,13 @@ def getRadius(obj,delta):
w2 = s2.Edges
w3 = Part.Line(s1.Vertexes[0].Point,s2.Vertexes[0].Point).toShape()
w4 = Part.Line(s1.Vertexes[-1].Point,s2.Vertexes[-1].Point).toShape()
newobj = Part.Face(Part.Wire(w1+[w3]+w2+[w4]))
newobj = FreeCAD.ActiveDocument.addObject("Part::Feature","Offset")
newobj.Shape = Part.Face(Part.Wire(w1+[w3]+w2+[w4]))
else:
newobj = Part.Face(obj.Shape.Wires[0])
newobj = FreeCAD.ActiveDocument.addObject("Part::Feature","Offset")
newobj.Shape = Part.Face(obj.Shape.Wires[0])
if not copy:
delete = obj.Name
elif copy:
newobj = None
if sym: return None
Expand Down Expand Up @@ -1586,6 +1593,8 @@ def getRadius(obj,delta):
select(newobj)
else:
select(obj)
if delete:
FreeCAD.ActiveDocument.removeObject(delete)
return newobj

def draftify(objectslist,makeblock=False,delete=True):
Expand Down

0 comments on commit cf1c022

Please sign in to comment.