Rhinocommon bake objects in different layers but the same group

Hi,

I would like to ask if it is possible to bake objects to rhino different layers but at the same time in the same group?

Currently I know that it is possible to add objects with attributes like this:
Rhino. Rhino Doc. Active Doc. Objects. AddSomeGeotype(geo, attributes)

Let say I have a point and a line, each of them are added to layer ‘points’ ‘lines’ but in rhino they stay as one group.

Manually I can group baked objects but no idea if it is possible to group while baking several objects in distinct layers.

the above will return the object ID’s
If you collect them and then put them in any group or layer you want.

Does that make sense?
-Willlem

Then question how to add objects in a group after I collect ids?

Hi Petras,

Does the below python example help?

import rhinoscriptsyntax as rs
import scriptcontext as sc


#sc.doc.Groups => Rhino.DocObjects.Tables.GroupTable for current doc

object_ids = rs.GetObjects('select obj')

new_group = 'NG'
if sc.doc.Groups.GroupNames(True):
    if not 'NG' in sc.doc.Groups.GroupNames(True):
        group_index = sc.doc.Groups.Find(new_group)
        print 'new'
else:
    group_index = sc.doc.Groups.Add(new_group)


#for clarity how you'd retrieve an idex by name
group_index = sc.doc.Groups.Find(new_group)

sc.doc.Groups.AddToGroup(group_index, object_ids)

-Willem