X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=share%2Fextensions%2Fdxf_outlines.py;h=176412ea3e279195606c14fc6fb6c447f22b38b7;hb=b8479bf7d4f211f77d10c09ae1829bd2d1bfa524;hp=a23949ee8f5cb01910c651d7897d7379286ed6e4;hpb=226d6d28236ad91c681c13bcf1cff4c1639b153b;p=inkscape.git diff --git a/share/extensions/dxf_outlines.py b/share/extensions/dxf_outlines.py index a23949ee8..176412ea3 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): @@ -44,8 +62,8 @@ class MyEffect(inkex.Effect): # NURB Curves: A Guide for the Uninitiated By Philip J. Schneider 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) + scale = 25.4/90.0 + h = unittouu(inkex.xml.xpath.Evaluate('/svg/@height',self.document)[0].value) path = '//path' for node in inkex.xml.xpath.Evaluate(path,self.document):