* Fixed arc directions * Turned max spline segment length preference option into a float * Fixed ellipses export
This commit is contained in:
parent
a1fab61ed6
commit
16ede0e55c
File diff suppressed because one or more lines are too long
|
@ -6,8 +6,8 @@
|
|||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>496</width>
|
||||
<height>524</height>
|
||||
<width>521</width>
|
||||
<height>528</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
|
@ -367,10 +367,23 @@
|
|||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="label_7">
|
||||
<property name="text">
|
||||
<string>Max Spline Segment: </string>
|
||||
<string>Max Spline Segment (mm): </string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
|
@ -378,21 +391,21 @@
|
|||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="Gui::PrefSpinBox" name="gui::prefspinbox_2">
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>60</width>
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
<widget class="Gui::PrefDoubleSpinBox" name="doubleSpinBox">
|
||||
<property name="toolTip">
|
||||
<string>When exporting splines to DXF, they are transformed in polylines. This value is the maximum length of each of the polyline segments. If 0, then the whole spline is treated as a straight segment.</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<double>9999.989999999999782</double>
|
||||
</property>
|
||||
<property name="value">
|
||||
<number>5</number>
|
||||
<double>5.000000000000000</double>
|
||||
</property>
|
||||
<property name="prefEntry" stdset="0">
|
||||
<cstring>maxsplinesegment</cstring>
|
||||
<cstring>maxsegmentlength</cstring>
|
||||
</property>
|
||||
<property name="prefPath" stdset="0">
|
||||
<cstring>Mod/Draft</cstring>
|
||||
|
@ -465,11 +478,6 @@
|
|||
<extends>Gui::FileChooser</extends>
|
||||
<header>Gui/PrefWidgets.h</header>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>Gui::PrefSpinBox</class>
|
||||
<extends>QSpinBox</extends>
|
||||
<header>Gui/PrefWidgets.h</header>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>Gui::PrefRadioButton</class>
|
||||
<extends>QRadioButton</extends>
|
||||
|
@ -480,6 +488,11 @@
|
|||
<extends>QCheckBox</extends>
|
||||
<header>Gui/PrefWidgets.h</header>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>Gui::PrefDoubleSpinBox</class>
|
||||
<extends>QDoubleSpinBox</extends>
|
||||
<header>Gui/PrefWidgets.h</header>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources/>
|
||||
<connections/>
|
||||
|
|
|
@ -1348,14 +1348,12 @@ def getArcData(edge):
|
|||
ve2 = edge.Vertexes[-1].Point
|
||||
ang1 = -math.degrees(DraftVecUtils.angle(ve1.sub(ce)))
|
||||
ang2 = -math.degrees(DraftVecUtils.angle(ve2.sub(ce)))
|
||||
|
||||
a1 = -DraftVecUtils.angle(ve1.sub(ce))
|
||||
a2 = -DraftVecUtils.angle(ve2.sub(ce))
|
||||
if round(a1,Draft.precision()) == round(a2,Draft.precision()):
|
||||
|
||||
if round(ang1,Draft.precision()) == round(ang2,Draft.precision()):
|
||||
return None,None, None, None
|
||||
if edge.Curve.Axis.z < 0.0:
|
||||
ang1, ang2 = ang2, ang1
|
||||
pseudoarc = Part.ArcOfCircle(edge.Curve,a1,a2).toShape()
|
||||
pseudoarc = Part.ArcOfCircle(edge.Curve,math.radians(ang1),math.radians(ang2)).toShape()
|
||||
if round(pseudoarc.Length,Draft.precision()) != round(edge.Length,Draft.precision()):
|
||||
ang1, ang2 = ang2, ang1
|
||||
|
||||
|
@ -1377,25 +1375,21 @@ def getArcData(edge):
|
|||
def getSplineSegs(edge):
|
||||
"returns an array of vectors from a Spline or Bezier edge"
|
||||
params = FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Mod/Draft")
|
||||
seglength = params.GetInt("maxsplinesegment")
|
||||
seglength = params.GetFloat("maxsegmentlength",5.0)
|
||||
points = []
|
||||
if seglength == 0:
|
||||
points.append(edge.Vertexes[0].Point)
|
||||
points.append(edge.Vertexes[-1].Point)
|
||||
else:
|
||||
if DraftGeomUtils.geomType(edge) == "BezierCurve":
|
||||
l = 1.0
|
||||
else:
|
||||
l = edge.Length
|
||||
points.append(edge.valueAt(0))
|
||||
points.append(edge.valueAt(edge.FirstParameter))
|
||||
if (edge.Length > seglength):
|
||||
nbsegs = int(math.ceil(edge.Length/seglength))
|
||||
step = l/nbsegs
|
||||
step = (edge.LastParameter-edge.FirstParameter)/nbsegs
|
||||
for nv in range(1,nbsegs):
|
||||
#print "value at",nv*step,"=",edge.valueAt(nv*step)
|
||||
v = edge.valueAt(nv*step)
|
||||
v = edge.valueAt(edge.FirstParameter+(nv*step))
|
||||
points.append(v)
|
||||
points.append(edge.valueAt(l))
|
||||
points.append(edge.valueAt(edge.LastParameter))
|
||||
return points
|
||||
|
||||
def getWire(wire,nospline=False,lw=True):
|
||||
|
@ -1412,9 +1406,7 @@ def getWire(wire,nospline=False,lw=True):
|
|||
# print "processing wire ",wire.Edges
|
||||
for edge in edges:
|
||||
v1 = edge.Vertexes[0].Point
|
||||
if len(edge.Vertexes) < 2:
|
||||
points.append(fmt(v1))
|
||||
elif DraftGeomUtils.geomType(edge) == "Circle":
|
||||
if DraftGeomUtils.geomType(edge) == "Circle":
|
||||
mp = DraftGeomUtils.findMidpoint(edge)
|
||||
v2 = edge.Vertexes[-1].Point
|
||||
c = edge.Curve.Center
|
||||
|
@ -1445,7 +1437,7 @@ def getWire(wire,nospline=False,lw=True):
|
|||
if not DraftGeomUtils.isClockwise(edge):
|
||||
bul = -bul
|
||||
points.append(fmt(v1,bul))
|
||||
elif (DraftGeomUtils.geomType(edge) in ["BSplineCurve","BezierCurve"]) and (not nospline):
|
||||
elif (DraftGeomUtils.geomType(edge) in ["BSplineCurve","BezierCurve","Ellipse"]) and (not nospline):
|
||||
spline = getSplineSegs(edge)
|
||||
spline.pop()
|
||||
for p in spline:
|
||||
|
@ -1499,7 +1491,7 @@ def writeShape(sh,ob,dxfobject,nospline=False,lwPoly=False):
|
|||
if not(e.hashCode() in processededges): loneedges.append(e)
|
||||
# print "lone edges ",loneedges
|
||||
for edge in loneedges:
|
||||
if (DraftGeomUtils.geomType(edge) in ["BSplineCurve","BezierCurve"]) and ((not nospline) or (len(edge.Vertexes) == 1)): # splines
|
||||
if (DraftGeomUtils.geomType(edge) in ["BSplineCurve","BezierCurve"]): # splines
|
||||
if (len(edge.Vertexes) == 1) and (edge.Curve.isClosed()):
|
||||
# special case: 1-vert closed spline, approximate as a circle
|
||||
c = DraftGeomUtils.getCircleFromSpline(edge)
|
||||
|
|
Loading…
Reference in New Issue
Block a user