From 643247197837b7c81fee4256b9d67ad98ac5b2e0 Mon Sep 17 00:00:00 2001 From: JazzyNico Date: Thu, 3 Dec 2009 16:13:26 +0100 Subject: [PATCH] New conversion factors added to inkex.py (ft, yd, m and km). Measure path extension now uses inkex.py conversion factors. --- share/extensions/inkex.py | 3 ++- share/extensions/measure.py | 23 +---------------------- 2 files changed, 3 insertions(+), 23 deletions(-) diff --git a/share/extensions/inkex.py b/share/extensions/inkex.py index b7e3e0e63..d36820692 100755 --- a/share/extensions/inkex.py +++ b/share/extensions/inkex.py @@ -38,7 +38,8 @@ u'xml' :u'http://www.w3.org/XML/1998/namespace' } #a dictionary of unit to user unit conversion factors -uuconv = {'in':90.0, 'pt':1.25, 'px':1, 'mm':3.5433070866, 'cm':35.433070866, 'pc':15.0} +uuconv = {'in':90.0, 'pt':1.25, 'px':1, 'mm':3.5433070866, 'cm':35.433070866, 'm':3543.3070866, + 'km':3543307.0866, 'pc':15.0, 'yd':3240 , 'ft':1080} def unittouu(string): '''Returns userunits given a string representation of units in another system''' unit = re.compile('(%s)$' % '|'.join(uuconv.keys())) diff --git a/share/extensions/measure.py b/share/extensions/measure.py index 8eacd40c6..68586530b 100644 --- a/share/extensions/measure.py +++ b/share/extensions/measure.py @@ -126,28 +126,7 @@ class Length(inkex.Effect): p = cubicsuperpath.parsePath(node.get('d')) num = 1 slengths, stotal = csplength(p) - ''' Wio: Umrechnung in unit ''' - if self.options.unit=="mm": - factor=25.4/90.0 # px->mm - elif self.options.unit=="pt": - factor=0.80 # px->pt - elif self.options.unit=="cm": - factor=25.4/900.0 # px->cm - elif self.options.unit=="m": - factor=25.4/90000.0 # px->m - elif self.options.unit=="km": - factor=25.4/90000000.0 # px->km - elif self.options.unit=="in": - factor=1.0/90.0 # px->in - elif self.options.unit=="ft": - factor=1.0/90.0/12.0 # px->ft - elif self.options.unit=="yd": - factor=1.0/90.0/36.0 # px->yd - else : - ''' Default unit is px''' - factor=1 - self.options.unit="px" - + factor = 1.0/inkex.unittouu('1'+self.options.unit) # Format the length as string lenstr = locale.format("%(len)25."+str(prec)+"f",{'len':round(stotal*factor*self.options.scale,prec)}).strip() self.addTextOnPath(self.group,0, 0,lenstr+' '+self.options.unit, id, self.options.offset) -- 2.30.2