Code

Extensions. Add option to choose dxf output units
authorAlvin Penner <penner@vaxxine.com>
Mon, 27 Dec 2010 16:18:05 +0000 (11:18 -0500)
committerAlvin Penner <penner@vaxxine.com>
Mon, 27 Dec 2010 16:18:05 +0000 (11:18 -0500)
share/extensions/dxf_outlines.inx
share/extensions/dxf_outlines.py

index fe8048a8e5ae870a8a08573332e98df628dd0b8c..8e8c54c6cd69a2f010ad45edc224a7daf24e9492 100644 (file)
@@ -9,11 +9,20 @@
                <page name="options" _gui-text="Options">
                        <param name="ROBO" type="boolean" _gui-text="use ROBO-Master type of spline output">false</param>
                        <param name="POLY" type="boolean" _gui-text="use LWPOLYLINE type of line output">true</param>
+                       <param name="units" type="enum" _gui-text="Units">
+                               <_item value="72./90">pt</_item>
+                               <_item value="1./15">pc</_item>
+                               <_item value="1.">px</_item>
+                               <_item value="25.4/90">mm</_item>
+                               <_item value="2.54/90">cm</_item>
+                               <_item value=".0254/90">m</_item>
+                               <_item value="1./90">in</_item>
+                               <_item value="1./1080">ft</_item>
+                       </param>
                </page>
                <page name="help" _gui-text="Help">
                        <_param name="inputhelp" type="description" xml:space="preserve">- AutoCAD Release 13 format.
 - assume svg drawing is in pixels, at 90 dpi.
-- assume dxf drawing is in mm.
 - only line and spline elements are supported.
 - ROBO-Master spline output is a specialized spline readable only by ROBO-Master and AutoDesk viewers, not Inkscape.
 - LWPOLYLINE output is a multiply-connected polyline, disable it to use a legacy version of the LINE output.</_param>
index 9c0ec35573f4e084339f30bc0942642fa3058b1c..6dd0de4774c04b17a586c65dbab9c09214621734 100755 (executable)
@@ -58,6 +58,7 @@ class MyEffect(inkex.Effect):
         inkex.Effect.__init__(self)
         self.OptionParser.add_option("-R", "--ROBO", action="store", type="string", dest="ROBO")
         self.OptionParser.add_option("-P", "--POLY", action="store", type="string", dest="POLY")
+        self.OptionParser.add_option("--units", action="store", type="string", dest="units")
         self.OptionParser.add_option("--tab", action="store", type="string", dest="tab")
         self.OptionParser.add_option("--inputhelp", action="store", type="string", dest="inputhelp")
         self.dxf = []
@@ -236,7 +237,9 @@ class MyEffect(inkex.Effect):
             self.dxf_add("  0\nLAYER\n  5\n%x\n100\nAcDbSymbolTableRecord\n100\nAcDbLayerTableRecord\n  2\n%s\n 70\n0\n  6\nCONTINUOUS\n" % (i + 80, self.layers[i]))
         self.dxf_add(dxf_templates.r14_style)
 
-        scale = 25.4/90.0
+        scale = eval(self.options.units)
+        if not scale:
+            scale = 25.4/90
         h = inkex.unittouu(self.document.getroot().xpath('@height', namespaces=inkex.NSS)[0])
         self.groupmat = [[[scale, 0.0, 0.0], [0.0, -scale, h*scale]]]
         doc = self.document.getroot()