summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAaron Spike <aaron@ekips.org>2006-02-08 13:54:22 +0000
committeracspike <acspike@users.sourceforge.net>2006-02-08 13:54:22 +0000
commitdc66195eee0d1ff588e7de14728d750df76f06e7 (patch)
treee9d4c3448a72c6ea16c1bff0df00ded482120f37
parentremove icon prerender time messages (diff)
downloadinkscape-dc66195eee0d1ff588e7de14728d750df76f06e7.tar.gz
inkscape-dc66195eee0d1ff588e7de14728d750df76f06e7.zip
Add unit conversion.
(bzr r106)
-rwxr-xr-xshare/extensions/dxf_outlines.py22
1 files changed, 20 insertions, 2 deletions
diff --git a/share/extensions/dxf_outlines.py b/share/extensions/dxf_outlines.py
index a23949ee8..cb68ef4d6 100755
--- a/share/extensions/dxf_outlines.py
+++ b/share/extensions/dxf_outlines.py
@@ -16,7 +16,25 @@ You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
'''
-import inkex, simplepath, cubicsuperpath
+import inkex, simplepath, cubicsuperpath, re
+
+uuconv = {'in':90.0, 'pt':1.25, 'px':1, 'mm':3.5433070866, 'cm':35.433070866, 'pc':15.0}
+def unittouu(string):
+ unit = re.compile('(%s)$' % '|'.join(uuconv.keys()))
+ param = re.compile(r'(([-+]?[0-9]+(\.[0-9]*)?|[-+]?\.[0-9]+)([eE][-+]?[0-9]+)?)')
+
+ p = param.match(string)
+ u = unit.search(string)
+ if p:
+ retval = float(p.string[p.start():p.end()])
+ else:
+ retval = 0.0
+ if u:
+ try:
+ return retval * uuconv[u.string[u.start():u.end()]]
+ except KeyError:
+ pass
+ return retval
class MyEffect(inkex.Effect):
def __init__(self):
@@ -45,7 +63,7 @@ class MyEffect(inkex.Effect):
self.dxf_add("999\nDXF created by Inkscape\n0\nSECTION\n2\nENTITIES")
scale = 5.0/18.0
- h = float(inkex.xml.xpath.Evaluate('/svg/@height',self.document)[0].value)
+ h = unittouu(inkex.xml.xpath.Evaluate('/svg/@height',self.document)[0].value)
path = '//path'
for node in inkex.xml.xpath.Evaluate(path,self.document):