[Python MaxPlus] Modify parameter of an existing object


I’m trying to modify a parameter of an existing object.

In the documentation , it provides an example of modifying an object:

obj = MaxPlus.Factory.CreateGeomObject(MaxPlus.ClassIds.Sphere)
obj.ParameterBlock.Radius.Value = 5.0
node = MaxPlus.Factory.CreateNode(obj)

It works as expected but that is pertaining to an object that is about to be created. When I used the code to modify an existing one, it throws an error:
RuntimeError: invalid parameter

Here’s the code I use

# Gets the selection of objects. In this case, only the sphere
objList = MaxPlus.SelectionManager.Nodes

for obj in objList:
	obj.ParameterBlock.Radius.Value = 15.0

Is there an additional code I am missing out?

Thank you for looking at my problem.

That’s because you are iterating nodes while the original code was accessing object. If you instead use obj.GetBaseObject().ParameterBlock.Radius.Value, everything will work as expected (provided you test it’s the right class).

1 Like

RE: iterating nodes while the original code was accessing object
Interesting. I never thought there is a major distinction. I initially though the object is in memory but the nodes is in actual scene. So I thought they are just one and the same referring to same thing.

Anyhow, your solution. Works as expected.

Thank you!