Create groups by layer with maxscript

Create groups by layer with maxscript

cadcajun
Participant Participant
208 Views
3 Replies
Message 1 of 4

Create groups by layer with maxscript

cadcajun
Participant
Participant

I'm pretty new to writing scripts, so forgive my ignorance if this is a trivial task.

I have 50+ scenes of bridges with their components organized into layers (columns, piers, decks, etc). I need a way to assign each mesh in a layer to a group that has the same name as that layer.

 

Our Layer hierarchy looks like this:

Screenshot 2025-06-13 172939.png

It needs to look like this: 

Screenshot 2025-06-13 173158.png

I haven't been able to find a workable solution to this issue anywhere online. Thanks!

0 Likes
Accepted solutions (1)
209 Views
3 Replies
Replies (3)
Message 2 of 4

dmitriy.shpilevoy
Collaborator
Collaborator
Accepted solution

Save your stuff and try this:

for i = 0 to (LayerManager.count - 1) do (
	thisLayer = LayerManager.getLayer i
	thisLayer.nodes &theNodes
	thisGroup = group theNodes name:(thisLayer.name) select:false
	thisLayer.addNode thisGroup
)

 

0 Likes
Message 3 of 4

A娘
Advocate
Advocate

it can't , the rule of group was a sub object can not group with anything , but sub object can located in different layers 

so , when you need group by layer , you must ungroup original groups first , that's not allowed most time

0 Likes
Message 4 of 4

cadcajun
Participant
Participant

Works exactly how I need it to, thank you so much!

0 Likes