Request: script or way to invert selected within same layer

just curious if someone has something floating around that would basically invert selected but only using objects on same layer to select? also this would only need to work with one layer for simplicity.

thank you in advance.

Hi @kleerkoat, you might try below. Works with multiple layers:

import rhinoscriptsyntax as rs

def DoSomething():
    
    sel_ids = rs.SelectedObjects(True, False)
    if not sel_ids: return
    
    layers = set([rs.ObjectLayer(obj_id) for obj_id in sel_ids])
    
    # uncomment below if you want only single layers
    # if len(layers) > 1: return
    
    for layer in layers: rs.ObjectsByLayer(layer, True)
    
    rs.UnselectObjects(sel_ids)
    
DoSomething()

_
c.

3 Likes

winner winner chicken dinner! time to go DoSomething() with this. :wink:

thank you!

1 Like

i really do hate to ask, but how would i put in a prompt if no item is preselected? this is the bee’s knee’s.

That would be

import rhinoscriptsyntax as rs

def DoSomething():
    
    sel_ids = rs.SelectedObjects(True, False)
    if not sel_ids:
        sel_ids = rs.GetObjects("Get some objects")
        if not sel_ids:
            return
    
    layers = set([rs.ObjectLayer(obj_id) for obj_id in sel_ids])
    
    # uncomment below if you want only single layers
    # if len(layers) > 1: return
    
    for layer in layers: rs.ObjectsByLayer(layer, True)
    
    rs.UnselectObjects(sel_ids)
    
DoSomething()

awesome! thank you kind sir! :grinning: