Unable to Modify the Input Port of the Math Node
-
Hi,
I'm trying to create a math node and modify its corresponding Input[2]. However, it gives me an error
TypeError: __setitem__ got unexpected type 'float'
I tried with an integer but it also gives me an error.Is there a way around this?
Thank you for looking at the problem.You can see the code here:
import c4d # Main function def main(): cube = c4d.BaseObject(c4d.Ocube) doc.InsertObject(cube) expresso = cube.MakeTag((c4d.Texpresso)) nodemaster = expresso.GetNodeMaster() math_node = nodemaster.CreateNode(nodemaster.GetRoot(), c4d.ID_OPERATOR_MATH, None, x=0, y=0) # This line works math_node[c4d.GV_MATH_FUNCTION_ID] = 2 # This line does not work. The '[2000,1001]' was retrieved by dragging the Input[2] to the console. math_node[2000,1001] = -1.0 c4d.EventAdd() # Execute main() if __name__=='__main__': main()
-
Hello,
the "input" parameters are dynamically created parameters. So it appears they need a little bit more love.
It seems to work using the fully qualified DescID and SetParamter().
subContainerID = c4d.DescLevel(2000, c4d.DTYPE_SUBCONTAINER, c4d.ID_OPERATOR_MATH) inputID = c4d.DescLevel(1001, c4d.DTYPE_REAL, c4d.ID_OPERATOR_MATH); paramID = c4d.DescID(subContainerID, inputID) math_node.SetParameter(paramID, 99.9, c4d.DESCFLAGS_SET_0)
best wishes,
Sebastian -
RE: appears they need a little bit more love.
Thanks for the clarification. The code works as expected!