Merge Nested Groups down into a single group

Hello Everyone,

Is possible to somehow merge nested groups down into a single group.
Either thought Rhino commands or a python script, maybe using script context sticky’s from all the id’s of the selected geometry in each of the groups selected.


Well, I guess the manual method would be to get all the objects, then run the Ungroup command multiple times until you’re sure none of the objects are grouped any more. Then, with the objects still selected, Group them once…

This can also be done relatively simply in Python, something like this:

import rhinoscriptsyntax as rs

def RegroupObjects():
    """Removes selected objects from all groups
    and regroups them into one master group"""
    objs=rs.GetObjects("Select objects to regroup",preselect=True)
    if not objs: return
    gName=rs.GetString("Name for new group?")
    if gName==None: return
    for obj in objs: rs.RemoveObjectFromAllGroups(obj)



Ah great thank you, yeah I had been using the ungroup lots of time then regroup option but though there must be a better way to automate the task . Thanks for the script that’s a great help

Script works great and have been able to make it run from a button. Though not found a way how to make Python scripts callable in the command line, even via macro’s. Searched online but with little success.

Well, there is a way to make this a plug-in - I haven’t really dealt with that - but the easiest way for me is to do the following:

  1. Save the script somewhere known - like

  2. Manually create an alias:
    ! _RunPythonScript "C:\Users\<username>\AppData\Roaming\McNeel\Rhinoceros\5.0\scripts\"

When you type the alias, it will run.

If you are going to do this with a bunch of scripts:

In the Python editor (_EditPythonScript), under Tools>Options, Files tab, set a path to the folder where you will keep all your scripts. Then in your aliases, all you need to have is:

! _RunPythonScript "Scriptname"

The script module will go looking to see if there is a script by that name in the search path, so you do not need to put in the absolute path. This is also good if you later decide to change the folder name or location, all you need to do is re-set the script path in the editor, not change all your aliases.