Code

Support for bulge in closing LWPOLYLINE segment. Patch by dormouse for gcodetools...
authorAlvin Penner <penner@vaxxine.com>
Mon, 19 Jul 2010 21:59:13 +0000 (17:59 -0400)
committerAlvin Penner <penner@vaxxine.com>
Mon, 19 Jul 2010 21:59:13 +0000 (17:59 -0400)
share/extensions/dxf_input.inx
share/extensions/dxf_input.py

index 70aae46d506b91114c21e7e8acf0daf043de5dff..10ef463c9f19d16959642272545c98b64adf3ede 100644 (file)
@@ -8,6 +8,7 @@
                <page name="options" _gui-text="Options">
                        <param name="auto" type="boolean" _gui-text="Use automatic scaling to size A4">true</param>
                        <param name="scale" type="string" _gui-text="Or, use manual scale factor">1.0</param>
+                       <param name="gcodetoolspoints" type="boolean" _gui-text="Gcodetools compatible point import">false</param>
                        <param name="sep1" type="description">-------------------------------------------------------------------------</param>
                        <param name="encoding" type="enum" _gui-text="Character Encoding">
                                <item value="latin_1">Latin 1</item>
index 7c5e4d0f91b390a80df04e02499879a34758622d..8439799dcf45a253ea43f0b6bee214d891924606 100644 (file)
@@ -65,7 +65,10 @@ def export_MTEXT():
 def export_POINT():
     # mandatory group codes : (10, 20) (x, y)
     if vals[groups['10']] and vals[groups['20']]:
-        generate_ellipse(vals[groups['10']][0], vals[groups['20']][0], w/2, 0.0, 1.0, 0.0, 0.0)
+        if options.gcodetoolspoints:
+            generate_gcodetools_point(vals[groups['10']][0], vals[groups['20']][0])
+        else:
+            generate_ellipse(vals[groups['10']][0], vals[groups['20']][0], w/2, 0.0, 1.0, 0.0, 0.0)
 
 def export_LINE():
     # mandatory group codes : (10, 11, 20, 21) (x1, x2, y1, y2)
@@ -118,6 +121,10 @@ def export_LWPOLYLINE():
             # optional group codes : (42) (bulge)
             iseqs = 0
             ibulge = 0
+            if vals[groups['70']][0] == 1:      # closed path
+                seqs.append('20')
+                vals[groups['10']].append(vals[groups['10']][0])
+                vals[groups['20']].append(vals[groups['20']][0])
             while seqs[iseqs] != '20':
                 iseqs += 1
             path = 'M %f,%f' % (vals[groups['10']][0], vals[groups['20']][0])
@@ -280,6 +287,11 @@ def generate_ellipse(xc, yc, xm, ym, w, a1, a2):
     attribs = {'d': path, 'style': style}
     inkex.etree.SubElement(layer, 'path', attribs)
 
+def generate_gcodetools_point(xc, yc):
+    path= 'm %s,%s 2.9375,-6.34375 0.8125,1.90625 6.84375,-6.84375 0,0 0.6875,0.6875 -6.84375,6.84375 1.90625,0.8125 z' % (xc,yc)
+    attribs = {'d': path, inkex.addNS('dxfpoint','inkscape'):'1', 'style': 'stroke:#ff0000;fill:#ff0000'}
+    inkex.etree.SubElement(layer, 'path', attribs)
+
 def get_line():
     return (stream.readline().strip(), stream.readline().strip())
 
@@ -301,6 +313,7 @@ colors = {  1: '#FF0000',   2: '#FFFF00',   3: '#00FF00',   4: '#00FFFF',   5: '
 parser = inkex.optparse.OptionParser(usage="usage: %prog [options] SVGfile", option_class=inkex.InkOption)
 parser.add_option("--auto", action="store", type="inkbool", dest="auto", default=True)
 parser.add_option("--scale", action="store", type="string", dest="scale", default="1.0")
+parser.add_option("--gcodetoolspoints", action="store", type="inkbool", dest="gcodetoolspoints", default=True)
 parser.add_option("--encoding", action="store", type="string", dest="input_encode", default="latin_1")
 parser.add_option("--tab", action="store", type="string", dest="tab", default="Options")
 parser.add_option("--inputhelp", action="store", type="string", dest="inputhelp", default="")