Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Maxscript Python addModifier

I'm writing maxscript in python and the following code throws a type error:

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 receive the following error:

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

while the type of morpher is Animatable(Morpher) and Animatable is a subclass of Modifier. Could someone help me with this?

Thank you in advance

like image 506
Reoku Avatar asked May 09 '26 15:05

Reoku


1 Answers

I think I found a possible solution (The only thing I know is that the MaxScript Listener doesn't 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 it is not correct or there is an easier or more understandable way.

like image 61
Reoku Avatar answered May 12 '26 06:05

Reoku



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!