[Closed] Python float script
I have the next setup: I have a sphere which has a morpher modifier. This morpher modifier has a certain amount of channels filled with morph targets aka sub animations. Now I want to add a controller to each of these subanimations, more specifically a controller with a float script. I have the code snippet that should work but when I go to the curve editor, the morph channels/ sub animations did not change controller, nor is the value of their controller changed.
import MaxPlus target = MaxPlus.INode.GetINodeByName('Sphere001')
#Retrieve the morpher modifier
mod = target.GetModifier(0)
#ID of a float script controller
id = MaxPlus.Class_ID(1233584870,1911625032)
#Create float controller
float_co = MaxPlus.Factory.CreateFloatController(id)
#Retrieve the first morph channel / sub animation
sub = mod.GetSubAnim(1)
#Controller is assigned to the sub animation
sub.AssignController(float_co,1)
#Basic test which assigns 20 to the sub animation
float_co.ParameterBlock.Script.Value = '20'
When I add a wrong value to the script, for example:
float_co.ParameterBlock.Script.Value = '=20'
I receive an error and the usual window when you manually add a controller to an object or node. However the strange thing is that at the top of the window: the name of the object to which it is connected, does not show. See figure for clarification:
Can someone tell me what I’m doing wrong? Thank you!
what do you expect to get? full path to your controller? list of all subanims where it’s reference used?
If in your test you are just wanting the value of the float script expression to be 20 then just do
float_co.ParameterBlock.Script.Value = '20'
Float script expressions do not need to be “=” anything it will simple use the last given value in the expression, for example:
mVal = 10+10
mVal
mVal will return 20 and that is the value passed through the expression.
I know this, this was just a simplified example to show my problem. When I use my regex as the script value, the curve of the associated subanimation or morph channel didn’t change. Therefore I entered a wrong expression to see what I would get and that’s when I got the image that is added to my question. I fixed it by using the MaxPlus.Core.EvalMAXScript() function. At that moment when I asked the question, I was wondering why it seemed that my float script wasn’t connected with anything. I coudn’t find it in my curve editor, the morph channel I thought I connected it with, didn’t change value etc. That’s another reason why I added the picture since you can see in the heading of that frame: Script Controller but no name of a morph channel behind it.
I expected to get in the image behind “Script Controller” the name of the sub animation / morph channel, since it didn’t show up in the curve editor. I had a hard time finding out to what the float script was connected to (therefore the “=20” to make the program throw an error). But like I said to PePeTD, I already fixed it using a EvalMAXScript, which I don’t really like. Therefore if you or PePeTD might know or have a suggestion what is missing in the code, please leave a comment. I would like to know and maybe other people in the future too.