[Closed] Opening nested groups
I’m fairly new to maxscript (but not 3D), and this is my first post on CGtalk.
My question is this: how do I script the opening of nested groups? I’ve tried a simple for loop that takes the closed “big group” and iterates through all the objects in the array, filtering out the geometry objects, and in theory opens each group. But it’s only opening the first level.
See the code:
BigGroup = selection as array
for g = 1 to BigGroup.count where classof g == Dummy do max group open
If I replace “max group open” at the end with print g.name, each group name is printed as expected. But when it’s written as above, it just says OK in the listener and opens the first level. (tried with 5 geometry objects nestedly grouped into 4 groups).
If you just want to simply get rid of the groups altogether, you can use the Explode option in the group pulldown…
As for the script, they may need to be opened in order sort of like wen doing them by hand?
A quick and dirty script to open the selected groups
for i in selection do
(
try(setGroupOpen i true)catch()
)
this one un groups the selection
for i in selection do
(
try(explodeGroup i)catch()
)
No need to do them in order, or at least I didn’t notice a need to when testing this.
Thanks Blue!
That’s exactly what I ended up using after re-re-reading the help files and thinking about the logic of it etc. I alse made a second script like this one but only opens groups in the entire scene which have objects with their material matching the currently selected mat in the editor.
My new task (which I’ll probably eventually make a new thread for if I pursue) it is making a dynamic “picture frame” object that behaves like a primitive with spinners to change frame size, shape, matte(s) sizes, picture, etc. Might be a little more than I can chew:shrug: I do have programming experience, just not MaxScript…