obj_arr = #() -- collect object(s) to process if selection.count == 0 then obj_arr = for o in geometry collect o -- on all scene objs (only geometry obj, no shape, cam, light, dummy ...) if selection.count != 0 then for o in selection do append obj_arr o -- on obj(s) selection if obj_arr.count != 0 then ( for o in obj_arr do ( n = o.name -- objects in group if (isGroupMember o AND classof o != Dummy) then ( -- if current obj is in a group AND is not a parent group (groupHead) n = o.parent.name -- then get his parent name as layer name appendIfUnique obj_arr o.parent -- add parent group to layer )--end if if LayerManager.getLayerFromName n == undefined -- IF layer's name does not already exist then NewLayer = LayerManager.newLayerFromName n -- THEN create a new layer with the object's name else NewLayer = LayerManager.getLayerFromName n -- ELSE get the layer already named with object's name NewLayer.addNode o )-- end loop )else( messagebox ("no object to process !") )--end