My MaxPlus packages have been a good way to get to know MaxPlus a little better and with practical examples sometimes I find myself hitting a wall, that’s what happened when I was trying to figure out how to check if an object was a FumeFx grid.
Normally, in Maxscript I would do a classof(object) and compare that to a string, should be more than enough, but getting to do that in MaxPlus became somewhat of a challenge since the documentation is still a bit rough. Thankfully with the help of Nicolas Genette and Larry Minton I had the problem solved and thought it would be good to share with you all.
import MaxPlus def getfumefxgrids(): """Helper function that returns a list with all FumeFx Grids in the scene """ nodes =  for node in MaxPlus.Core.GetRootNode().Children: if 'fumefx' in node.Object.GetClassName().lower(): nodes.append(node) return nodes
And that’s basically it, node.Object.GetClassName() which returns the top of the stack class name OR node.BaseObject.GetClassName() to get the base object class name, if you have modifiers on the object, these results might be different.
On a side note, this always returns a string, which in some cases might lead to having the same class name for two different types, the only way to uniquely check the class is via superclass id and class id.
Hope this helps and prevents hours of banging your head against the MaxPlus documentation 🙂
Awesome – thanks!
That’s cool, I just ran into this problem myself and solved it slightly differently. Man the documentation sucks, I hate spending literally an hour just trying to figure out how to print a list of all cameras in a scene! Here’s my solution:
for c in node.Children:
for d in GenerateChildNodes(c):
for n in GenerateChildNodes(MaxPlus.Core.GetRootNode()):
if n.Object.GetSuperClassID() == MaxPlus.SuperClassIds.Camera:
Spencers code produces an error. “c is referenced before assignment”. Perhaps repost the code with proper formatting. I did format it and it still gives the error.
No, sorry, it does work. My fat fingers put in too many space. Sorry.