Maxscript Python addModifier

I am writing maxscript in python and the following code throws an error like:

import MaxPlus

res = MaxPlus.Core.GetRootNode()
#This is just as example that I use the first child.
child = MaxPlus.INode.GetChild(res,0)

morpherFP = MaxPlus.FPValue()
MaxPlus.Core.EvalMAXScript("Morpher()", morpherFP)
morpher = MaxPlus.FPValue.Get(morpherFP)

MaxPlus.INode.AddModifier(child, morpher)

      

And from the MaxScript listener, I always get the following error:

type 'exceptions.TypeError' in method 'INode_AddModifier', argument 2 of type 'Autodesk :: Max :: Modifier' "

while morpher type is Animatable (Morpher) and Animatable is a subclass of Modifier. Can anyone help me with this?

Thank you in advance

+3


source to share


1 answer


I think I found a possible solution (the only thing I know is that the MaxScript Listener does not throw an error):

import MaxPlus

res = MaxPlus.Core.GetRootNode()
#I use the first child as example
child = MaxPlus.INode.GetChild(res,0)
morpher = MaxPlus.Factory.CreateObjectModifier(MaxPlus.ClassIds.Morpher)
MaxPlus.INode.AddModifier(child, morpher) 
# the following also seems to work aka it does not throw any errors
child.InsertModifier(morpher,1)

      



Let me know if this is not correct or if there is an easier or clearer way.

+1


source







All Articles