Skip to content

Commit

Permalink
Draft: issue #1524 - Added Wandererfan's fix to displayExternal
Browse files Browse the repository at this point in the history
  • Loading branch information
yorikvanhavre committed May 8, 2014
1 parent 96bba08 commit 8e1ebcd
Showing 1 changed file with 12 additions and 11 deletions.
23 changes: 12 additions & 11 deletions src/Mod/Draft/DraftGui.py
Expand Up @@ -130,23 +130,24 @@ def makeFormatSpec(decimals=4,dim='Length'):
return fmtSpec

def displayExternal(internValue,decimals=4,dim='Length'):
'''return an internal value (ie mm) Length converted for display according
'''return an internal value (ie mm) Length or Angle converted for display according
to Units Schema in use.'''
from FreeCAD import Units
if dim == 'Length':
qty = FreeCAD.Units.Quantity(internValue,FreeCAD.Units.Length)
parts = (qty.getUserPreferred()[0]).split()
qty = FreeCAD.Units.Quantity(1.0,FreeCAD.Units.Length)
pref = qty.getUserPreferred()
conversion = pref[1]
uom = pref[2]
elif dim == 'Angle':
qty = FreeCAD.Units.Quantity(internValue,FreeCAD.Units.Angle)
qty = FreeCAD.Units.Quantity(1.0,FreeCAD.Units.Angle)
pref=qty.getUserPreferred()
parts = (qty.getUserPreferred()[0]).split()
val = (qty.getUserPreferred()[0]).split()[0]
um = parts[1].decode('latin-1')
parts = (val,um)
conversion = pref[1]
uom = pref[2].decode('latin-1')
else:
parts = (internValue,'??')
fmt = "{0:."+ str(decimals) + "f} "+ parts[1]
displayExt = fmt.format(float(parts[0].replace(",",".")))
conversion = 1.0
uom = "??"
fmt = "{0:."+ str(decimals) + "f} "+ uom
displayExt = fmt.format(float(internValue) / float(conversion))
return displayExt

#---------------------------------------------------------------------------
Expand Down

0 comments on commit 8e1ebcd

Please sign in to comment.