group properties issue

I am trying to check if there is only one "main/top level" group present in my maxfile. Basically i want to check that everything has been grouped at a top level and doesn't consist of 10's, possibly 100's of of objects.

I cannot seem to work out how to check that the group count for the current scene is not equal to 1.

Hopefully it looks something like. Tried many variations but a bit confused now on what options to try.

if groupHead.count != 1 do (
messagebox "more than one group present"
)

Any help would be much appreciated.

Comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
kimarotta's picture

maybe... group_arr = for o

maybe...

group_arr = for o in objects where isValidNode o AND isGroupHead o collect o
 
if group_arr.count != 1 do (
messagebox "more than one group present"
)

kimarotta.com.br
3d Artist  

ce89's picture

Thanks for the quick reply

Thanks for the quick reply Kimarotta,

It seems to work for objects that are grouped seperatley, but if i have groups within a top level group it still thinks there are more than one group present. If all scene groups are grouped at a top level i was wanting it to only see it as one group.

Hope this makes sense.

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.