Skip to content

Added TypedFloat to preserve maxscript double/float

Pre-release
Pre-release
Compare
Choose a tag to compare
@MHendricks MHendricks released this 22 Nov 23:07
· 1 commit to master since this release

In some cases maxscript expects a float value or a double value. Because python does not differentiate, we needed to preserve this relationship in our wrapper functions. Now instead of converting a maxscript double or float to python's float, it converts it to a Py3dsMax.TypedFloat object. You can check if it's a float by checking myFloat.isFloat. True means its a float, False means its a double.

In practice, all you need to do is call mxs.Float(value) if the maxscript function requires a float:

mxs.mixdown(nativeRoot.controller.mixer, False, False, 6, False, mxs.Float(166.15))

Here is a quick unit test:

# Floats:
y = mxs.Float(1.5)
assert(y == 1.5)
assert(str(mxs.classOf(y)) == 'Float')
y = Py3dsMax.TypedFloat(1.5, True)
assert(y == 1.5)
assert(str(mxs.classOf(y)) == 'Float')
# Doubles
y = mxs.Double(1.5)
assert(y == 1.5)
assert(str(mxs.classOf(y)) == 'Double')
y = Py3dsMax.TypedFloat(1.5)
assert(y == 1.5)
assert(str(mxs.classOf(y)) == 'Double')