I'm looking for a script to group each object in a new group

Hello everybody, I’m googling around trying to find a script that put every single object selected to a group. I mean if I select 1000 objects the script should create 1000 new groups and put every single object to a single group. Best of the best should be that the script recognises if any object is (geometrically) contained by another one. If it occours the two objects should be grouped togheter.

Example: I have the word “CIAO” as curves on a 3d surface. The script should create 4 new group and place each letter in a group. C is 1 curve on 1 group. I is the same. A is made by 2 curves and should go in the same group. Also O 2 curves in a different group than C I A.

Sorry I’m really poor on scripting and after some trials I gave up :triumph:

Thank you for any help!

OK, but why do you need this? --Mitch

:sweat_smile: I understand that looks nonsense… but I have a CNC plugin (not editable, not done by me) that uses groups for XYZ movements. I’m sure I’ll be the only one on the world needing it :wink:

Hey, try this:

import rhinoscriptsyntax as rs

strObjID = rs.GetObjects("Select objects")

for i in range(len(strObjID)):
    group = rs.AddGroup()
    rs.AddObjectToGroup(strObjID[i], group)

Thank you very much Octav1an! This will save me some time :smiley:
Any suggestion on how to implement the “enhanced” version that check for objects inside another?