このみの問題ですが。
DraftGui.py内です。
Code: Select all
def displayExternal(internValue,decimals=None,dim='Length',showUnit=True,unit=None):
'''return an internal value (ie mm) Length or Angle converted for display according
to Units Schema in use. Unit can be used to force the value to express in a certain unit'''
from FreeCAD import Units
if dim == 'Length':
q = FreeCAD.Units.Quantity(internValue,FreeCAD.Units.Length)
if not unit:
if (decimals == None) and showUnit:
return q.UserString
conversion = q.getUserPreferred()[1]
uom = q.getUserPreferred()[2]
else:
uom = unit
internValue = q.getValueAs(unit)
conversion = 1
elif dim == 'Angle':
return FreeCAD.Units.Quantity(internValue,FreeCAD.Units.Angle).UserString
else:
conversion = 1.0
if decimals == None:
decimals = 2
uom = "??"
if not showUnit:
uom = ""
fmt = "{0:."+ str(decimals) + "f} "+ uom
displayExt = fmt.format(float(internValue) / float(conversion))
displayExt = displayExt.replace(".",QtCore.QLocale().decimalPoint())
return displayExt
Code: Select all
def displayExternal(internValue,decimals=None,dim='Length',showUnit=True,unit=None):
'''return an internal value (ie mm) Length or Angle converted for display according
to Units Schema in use. Unit can be used to force the value to express in a certain unit'''
from FreeCAD import Units
if dim == 'Length':
q = FreeCAD.Units.Quantity(internValue,FreeCAD.Units.Length)
if not unit:
if (decimals == None) and showUnit:
return q.UserString
conversion = q.getUserPreferred()[1]
uom = q.getUserPreferred()[2]
else:
uom = unit
internValue = q.getValueAs(unit)
conversion = 1
elif dim == 'Angle':
uq = FreeCAD.Units.Quantity(internValue,FreeCAD.Units.Angle)
uom = ""
internValue = uq.Value
conversion = 1
else:
conversion = 1.0
if decimals == None:
decimals = 2
uom = "??"
if not showUnit:
uom = ""
fmt = "{0:."+ str(decimals) + "f} "
displayExt = fmt.format(float(internValue) / float(conversion))
if '.' in displayExt :
displayExt = displayExt.rstrip("0 ")
displayExt = displayExt.rstrip(".")
displayExt = displayExt.replace(".",QtCore.QLocale().decimalPoint()) + uom
return displayExt
今回はこれで終わりの予定です。