maur_2005 opened this issue on Dec 05, 2020 ยท 8 posts
structure posted Wed, 09 December 2020 at 1:50 PM Forum Coordinator
class getunits:
def analyze ( self , event = None ):
units, uDisplay = self.unitCalc()
cType = (u'PNU',u'in',u'ft',u'mm',u'cm',u'm')[['PNU','Inches','Feet','MM','CM','Metres'].index(units)]
convert = self.ConvertToPNU(1.0, cType)
return units
def unitCalc( self, event = None ):
prefs=os.path.join(poser.PrefsLocation(),'poser.ini')
if os.path.exists(prefs):
pref=open(prefs,'rb').readlines()
for line in pref:
if line.lower().startswith('unit'):
line = line.split(' ')
if 'FACTOR' in str(line[0]):
units = float((line)[1])
uDisplay, pType = float(self.response(units)[1]) , self.response(units)[0]
return pType, uDisplay
def ConvertToPNU( self, value = 1, unit = '' ):
multiplier = (1.0, 103.2, 8.6, 2621.28, 262.128, 2.62128)[[u'PNU', u'in', u'ft', u'mm', u'cm', u'm'].index(unit)]
return value * multiplier
getunits = getunits()
analyze = getunits.analyze()
print analyze
get your own units or convert them using this script ( will need a little modification for purpose).
Locked Out