pymel.core.system.convertUnit

convertUnit(*args, **kwargs)

This command converts values between different units of measure. The command takes a string, because a string can incorporate unit names as well as values (see examples).

Flags:

Long Name / Short Name Argument Types Properties
fromUnit / f unicode ../../../_images/create.gif
  The unit to convert from. If not supplied, it is assumed to be the system default. The from unit may also be supplied as part of the value e.g. 11.2m (11.2 meters).
toUnit / t unicode ../../../_images/create.gif
  The unit to convert to. If not supplied, it is assumed to be the system default Flag can have multiple arguments, passed either as a tuple or a list.

Derived from mel command maya.cmds.convertUnit

Example:

import pymel.core as pm

# Returns string "4.80315in", which is 12.2cm in inches.
pm.convertUnit( '12.2', fromUnit='cm', toUnit='in' )
# Result: u'4.80315in' #

# Returns string "3.499563yd", which is 3.2m in yards.
pm.convertUnit( '3.2m', toUnit='yard' )
# Result: u'3.499563yd' #

# Returns float value 13.716, which is 5.4 inches in cm (default system units).
pm.convertUnit( '5.4', fromUnit='inch' )
# Result: u'13.716' #