Pymxs perform 'as' convert operation?

how to perform ‘as’ convert operation in pymxs ?

In maxscript, for example:

– make a quat
q = quat 0 0 0 1
– convert to matrix
m = q as matrix3

and now, how can i do that in pymxs ?

from pymxs import runtime as rt
q = rt.quat(0,0,0,1) # make a quat
m = ?? # how to conver it to matrix

you need to make a globally accessible maxscript function and then you can call it from python:

MyUtils.ms:

// Wrap in a struct to provide a namespace:
struct MyUtils(
    fn ConvertMxsType value type =(
        value as type 
    )
)

// Create a global instance:
MyUtilsInstance = MyUtils()

from python:

from pymxs import runtime as mxRt

# Make sure your MyUtils.ms file has been evaluated so the struct is available in pymxs.runtime:
mxRt.FileIn("MyUtils.ms")

q = rt.quat(0,0,0,1) # make a quat
# Convert using the function:
m = mxRt.MyUtilsInstance.ConvertMxsType(q, mxRt.Matrix3)
print(m)

its a way to do it, but a little bit complicated…
:upside_down_face:

Welcome to 3DsMax!
The issue is that the pymxs is just an automatic wrapper - there are little to no convenience functions added so you have to do those yourself.