Creating a new group

Hi,
I’m trying to do something pretty simple - creating a group from all objects in a layer.

This is my script:

import rhinoscriptsyntax as rs
layers = rs.LayerNames()
if layers:
    for layer in layers:
    	thisObjSet = rs.ObjectsByLayer(layer)
    	if thisObjSet:
    		name = str(layer)
    		ng = rs.AddObjectsToGroup(thisObjSet, name)
    		if ng:
    			print "Grouped " + name

There doesn’t seem to be a ‘createGroup’ function that I can find, and the help in the docs for the command seems to suggest using a unused name should do.

When I run this script, it steps through but the rs.AddObjectsToGroup(thisObjSet, name) call fails.

Any ideas about what I’m doing wrong?

thanks
Peter

You need to use rs.AddGroup(group_name) specifying a name to first create a group, then assign objects to the group as you have done above.

Creating a group without specifying the name generates a group with an incremental name, e.g. Group12

Hope that helps

Thanks Mate,

I figured there should be something like that but that command isn’t in the Dash formatted docset I use.
I wonder what else is missing :smile:

cheers Peter