MaxPlus & Custom Attributes

Trying to wrap my head around how to deal with adding custom attributes with MaxPlus (or how to even get at them as they do not seem to show up in Paramaterblock), if it’s even possible.

Anyone in the know?

Hey Sune, I’m also struggling. We have all our data stored by means of appData and all of the AppDataChunk functionality was stripped from the python api. I was also looking to possibly move this data to custom attributes, but so far I’m stuck executing Maxscript from python.

After some painfully slow investigation, as I also wanted to access the Custom Attributes, I found the solution.


node = MaxPlus.INode.GetINodeByName('xxx') 

#Print all custom attributes
for attr in node.BaseObject.GetCustomAttributeContainer()[0].GetParameterBlock():
    print attr.Name

#Print value of specific attribute, in this case ParamXXX
print node.BaseObject.GetCustomAttributeContainer()[0].GetParameterBlock().ParamXXX.Value

#Change value of ParamXXX
node.BaseObject.GetCustomAttributeContainer()[0].GetParameterBlock().ParamXXX.Value = 'A B C. Its easy as, 1 2 3'

I don’t know if we can have a CustomAttributeContainer of index above 0, so if you have trouble finding what you want, try playing with the different indexes.

Hope this helps anyone else stuck, so they don’t have to spend as much time as I did to do something that should be quite simple :laugh:

Also, now I am looking at how to add and delete these attributes, if anyone gets there before me, please post the answer here in case I haven’t got there yet :smiley:

1 Like

Also trying to figure out how to add custom attributes via Python.
No luck yet.
Anyone have any?

-Len

Sorry haven’t looked at it since that post. MaxPlus can be so painful to work with sometimes because it just doesn’t explain much how you’re suppose to get things done.
The other day I was trying to create Shapes/Splines via MaxPlus, decided it wasn’t worth it, and just ran Maxscript within my python scripts (probably slower, definately inconvenient, but got the job done).

If you’re really stuck, it may get you where you need to go until someone finds out how to do it in pure MaxPlus.

How I go about mixing it up


#Re create some maxscript functions
rawAddShape = '%s = splineshape()'
rawAddSpline = '%s = addNewSpline %s'
rawAddKnot = 'addKnot %s %s #corner #line [%s,%s,%s]'
rawUpdateShape = 'updateShape %s'

#Use the functions
newShape = 'newShape'
newShapeIndex = 'newShapeIndex'
MaxPlus.Core_EvalMAXScript(rawAddShape % (newShape))
MaxPlus.Core_EvalMAXScript(rawAddSpline % (newShapeIndex, newShape))

And then you can use the example from my past post to get/edit the new custom attributes you’ve added using maxscript.