Coercing MAXScript Values

Although pymxs supports conversion between many Python and MAXScript types, and most "non-Pythonic" constructs (such as passing arguments by reference), you may find some MAXScript commands are simply impossible to replicate in Python. For example, using the "as" coercion syntax. In MAXScript you can do something like this:

selectedFaces = getFaceSelection selection[1] -- returns BitArray value
myArray = selectedFaces as Array

In Python this is not possible. Instead, we can create a function in MAXScript that does this coercion internally and returns the result. Global functions will be visible to the MAXScript system for the lifetime of the 3ds Max instance. You can do this in a separate MAXScript script, or within your Python script using MaxPlus.Core.EvalMAXScript(), for example:

MaxPlus.Core.EvalMAXScript("fn b2a b = (return b as Array)")
rt.b2a(selectedFaces)