Skip to content

Commit

Permalink
Draft: Use DXF OCS when importing circles and arcs to Part shapes
Browse files Browse the repository at this point in the history
  • Loading branch information
Roy-043 committed Oct 10, 2023
1 parent e0f73af commit 72cb34d
Showing 1 changed file with 17 additions and 15 deletions.
32 changes: 17 additions & 15 deletions src/Mod/Draft/importDXF.py
Expand Up @@ -992,21 +992,22 @@ def drawArc(arc, forceShape=False):
-----
Use local variables, not global variables.
"""
v = vec(arc.loc)
pl = placementFromDXFOCS(arc)
rad = vec(arc.radius)
firstangle = round(arc.start_angle, prec())
lastangle = round(arc.end_angle, prec())
circle = Part.Circle()
circle.Center = v
circle.Radius = vec(arc.radius)
try:
if (dxfCreateDraft or dxfCreateSketch) and (not forceShape):
pl = placementFromDXFOCS(arc)
return Draft.make_circle(circle.Radius, pl, face=False,
return Draft.make_circle(rad, pl, face=False,
startangle=firstangle,
endangle=lastangle)
else:
return circle.toShape(math.radians(firstangle),
math.radians(lastangle))
circle = Part.Circle()
circle.Radius = rad
shape = circle.toShape(math.radians(firstangle),
math.radians(lastangle))
shape.Placement = pl
return shape
except Part.OCCError:
warn(arc)
return None
Expand Down Expand Up @@ -1043,16 +1044,17 @@ def drawCircle(circle, forceShape=False):
-----
Use local variables, not global variables.
"""
v = vec(circle.loc)
curve = Part.Circle()
curve.Radius = vec(circle.radius)
curve.Center = v
pl = placementFromDXFOCS(circle)
rad = vec(circle.radius)
try:
if (dxfCreateDraft or dxfCreateSketch) and (not forceShape):
pl = placementFromDXFOCS(circle)
return Draft.make_circle(circle.radius, pl)
return Draft.make_circle(rad, pl, face=False)
else:
return curve.toShape()
curve = Part.Circle()
curve.Radius = rad
shape = curve.toShape()
shape.Placement = pl
return shape
except Part.OCCError:
warn(circle)
return None
Expand Down

0 comments on commit 72cb34d

Please sign in to comment.