Wish: SelLayerSelected

Hi guys,
When working on large DWG’s from architects I often want to select objects that are on the same layer as a given curve I pick from the drawing so I think a SelLayerSelected would be great to include in Rhino.

I have my own scripts that I use for this though, so if anybody want’s it then here it is:

### --- Select objects on same layer as selected
### --- by Holo 2019
import rhinoscriptsyntax as rs
obj_id=rs.GetObject("Select them", preselect=True)
if obj_id:
    visibleObjects=rs.VisibleObjects(view=None,select=False, include_lights=False, include_grips=False)
    for obj in visibleObjects:
        if rs.ObjectLayer(obj)==layer:
1 Like

Similar request:

Hi Jorgen - this is for getting pre-selection to work, correct? otherwise

_-SelLayer _Pick

Do I understand correctly?

btw, need to turn redraw back on - copy paste typo in your script =)


You guys… you hide important tools in hidden commands like we are all easteregghunting all day long… :smiley:
Any good reason that didn’t make it into the GUI as a button?

…and of course I mainly use it with preselection, so yes, let’s pretend that was the reason, and not me being smart :wink:

(Oh, and the redraw I just added, and obviously forgot to turn back on, so well spotted!!)

Hi Jorgen - I see the RMB of SelLayer is SelLayerNumber, which, I confess, I did not even know or recall was a thing. I’d replace that RMB with-SelLayer _Pick. I don’t think I’ll do it in the default though - it might be pulling the rug out from someone’s workflow.



hi Jorgen, Pascal,

This is something I use all the time, the only suggestion for the -SelLayer _Pick command would be to add additional option “FromSelected”, maybe at the same level as _Pick? So it works with preselection.
With that, it would be just a click away to select all objects from selected objects layers.
I have a script that does it currently but it is so handy that you should consider adding it to Rhino as a regular command.

    Option Explicit

    Call DIG_SelByLayerFromObjects()
    Sub DIG_SelByLayerFromObjects()

    	Dim arrPre : arrPre = Rhino.SelectedObjects()
    	Call Rhino.Command("-_SelLayer _Pick")
    	Rhino.EnableRedraw False
    	If Not isnull(arrPre) Then
    		Dim i,arrL
    		Dim Dict : Set Dict = CreateObject("Scripting.Dictionary")
    		Dim arrO : arrO = Rhino.SelectedObjects()
    		For i=0 To Ubound(arrO)
    			If Not Dict.Exists(Rhino.ObjectLayer(arrO(i))) Then Call Dict.Add(Rhino.ObjectLayer(arrO(i)), True)
    		arrL = Dict.Keys
    		For i=0 To Ubound(arrL)
    			Call Rhino.SelectObjects(Rhino.ObjectsByLayer(arrL(i)))
    	End If
    	Rhino.EnableRedraw True
    End Sub



1 Like