AddGroup custom name not returned

G’day Everyone,

For some reason I cannot get the following grouping script to work. No group is created.

        group = rs.AddGroup(strName)
        #group = rs.AddGroup()
        if group:
            groupobjs = []
            for obj in borderSurf:
            intg = rs.AddObjectsToGroup(groupobjs, group)

group has value of None
strName is a string

If I go with the default name method (commented out) it all works fine. A name is assigned to group.

Rhino 5 SR14



On my phone so brief reply,

rs.AddObjectsToGroup(groupobjs, group)

Should be

rs.AddObjectsToGroup(groupobjs, strName)

If you want to make sure a group exists use
RS.IsGroup(). (iirc)

So RS.AddGroup() does not return a group.


Thank you @Willem, that all works.

Now for the documentation to clarify that or AddGroup to actually return the name as it claims…


Still love rhino and this forum, wouldn’t have a chance doing this with any other software.

@Willem, @Ncik,

Dunno, AddGroup() is supposed to return the group name. Both of these work here:

import rhinoscriptsyntax as rs
group = rs.AddGroup("MyGroup")
print group


Option Explicit
Call Test()
Sub Test()	
	Dim group	
	group = Rhino.AddGroup("MyGroup")
End Sub


Both vb and python rhinoscriptsyntax return the group name. Note if the name already exists, it also adds a number after the name to make the group name unique, so the added group name might not be the same as strName… Just a heads-up.


Hi Mitch, @Ncik

You are right, AddGroup() indeed returns the groupname
Thanks for correcting me

I’m not sure what caused the initial issue than.


Yep, me neither… ???

Thanks for continuing this. Upon even further testing it appears as though the groupname isn’t returned (None returned) if the assigned group name already exists…well that seems to be the issue. I ran the full command twice, first time returned the groupname properly, second time (on a different object that had the same name to be assigned to the group) it returned None and crashed out of the command. This was repeatable on a second pair of objects with the same groupname to be assigned to each, first worked, second didn’t.

The simplest solution is probably to explicitly make the groupname unique to avoid this issue. That won’t create any foreseeable issues down the line.

Remember this is R5, not R6.

Thanks @Helvetosaur, is this with R5 or R6?

In Rhino 5 and 6 AddGroup() with no arguments creates unique name.

In Rhino 5 passing a name argument will add it if it doesn’t exist otherwise it returns None. In Rhino 6 a number will be appended to the passed name if it already exists to create a unique name.

1 Like

Thanks @Alain.

Yes, I was testing in V6, not V5… --Mitch