Skip to content

Commit

Permalink
Merge branch 'master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
plgarcia committed Oct 31, 2017
2 parents 2435db7 + 5657acd commit 34ce404
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 14 deletions.
32 changes: 18 additions & 14 deletions src/Mod/Draft/Draft.py
Expand Up @@ -2676,6 +2676,12 @@ def addRadiusConstraint(edge):
except AttributeError:
pass

def convertBezier(edge):
if DraftGeomUtils.geomType(edge) == "BezierCurve":
return(edge.Curve.toBSpline(edge.FirstParameter,edge.LastParameter).toShape())
else:
return(edge)

rotation = None
for obj in objectslist:
ok = False
Expand Down Expand Up @@ -2779,17 +2785,13 @@ def addRadiusConstraint(edge):
FreeCAD.Console.PrintWarning(translate("draft","Unable to guess the normal direction of this object"))
rotation = FreeCAD.Rotation()
norm = obj.Placement.Rotation.Axis
for e in shape.Edges:
if DraftGeomUtils.geomType(e) in ["BSplineCurve","BezierCurve"]:
if DraftGeomUtils.geomType(e) == "BezierCurve":
bsp = e.Curve.toBSpline(e.Curve.FirstParameter,e.Curve.LastParameter)
else:
bsp = e.Curve
nobj.addGeometry(bsp)
nobj.exposeInternalGeometry(nobj.GeometryCount-1)
ok = True
#FreeCAD.Console.PrintError(translate("draft","BSplines and Bezier curves are not supported by this tool"))
#return None
if not shape.Wires:
for e in shape.Edges:
# unconnected edges
newedge = convertBezier(e)
nobj.addGeometry(DraftGeomUtils.orientEdge(newedge,norm,make_arc=True))
addRadiusConstraint(newedge)

# if not addTo:
# nobj.Placement.Rotation = DraftGeomUtils.calculatePlacement(shape).Rotation

Expand All @@ -2798,9 +2800,10 @@ def addRadiusConstraint(edge):
last_count = nobj.GeometryCount
edges = wire.OrderedEdges
for edge in edges:
newedge = convertBezier(edge)
nobj.addGeometry(DraftGeomUtils.orientEdge(
edge,norm,make_arc=True))
addRadiusConstraint(edge)
newedge,norm,make_arc=True))
addRadiusConstraint(newedge)
for i,g in enumerate(nobj.Geometry[last_count:]):
if edges[i].Closed:
continue
Expand Down Expand Up @@ -2840,8 +2843,9 @@ def addRadiusConstraint(edge):
else:
for wire in shape.Wires:
for edge in wire.OrderedEdges:
newedge = convertBezier(edge)
nobj.addGeometry(DraftGeomUtils.orientEdge(
edge,norm,make_arc=True))
newedge,norm,make_arc=True))
ok = True
formatObject(nobj,obj)
if ok and delete and obj.isDerivedFrom("Part::Feature"):
Expand Down
3 changes: 3 additions & 0 deletions src/Mod/Draft/DraftGeomUtils.py
Expand Up @@ -570,6 +570,9 @@ def orientEdge(edge, normal=None, make_arc=False):
elif make_arc and isinstance(edge.Curve,Part.Circle) and not edge.Closed:
return Part.ArcOfCircle(edge.Curve, edge.FirstParameter,
edge.LastParameter,edge.Curve.Axis.z>0)
elif make_arc and isinstance(edge.Curve,Part.Ellipse) and not edge.Closed:
return Part.ArcOfEllipse(edge.Curve, edge.FirstParameter,
edge.LastParameter,edge.Curve.Axis.z>0)
return edge.Curve

def mirror (point, edge):
Expand Down

0 comments on commit 34ce404

Please sign in to comment.