What command select all objects on layer the selected object is on?

I have this as a script:

SelectAllObjsOnObjLayers.py (253 Bytes)

import rhinoscriptsyntax as rs

objs=rs.GetObjects("Select objects",preselect=True)
if objs:
    rs.EnableRedraw(False)
    layers=set()
    for obj in objs: layers.add(rs.ObjectLayer(obj))
    for layer in layers: rs.ObjectsByLayer(layer,True)
2 Likes

A post was split to a new topic: Automate filaments trajectories?

Suddenly it worked again and I finally understood why after a few tests. If the layer of the selected object(s) is or are in a folder that is not expanded, the command won’t work at all… but if on the layer panel you expand it, select an object and do sellayer it works!
(I don’t know what changed about layer folders but they are very slow to expand as well)
Still the purpose of folders in layer panel are to keep some closed, so this shouldn’t happen, right?

Hi Quentin -

2024-01-17 - SelLayer

Are you doing something differently than what I’m doing here?
-wim

I already had your script since last year and was about to post it here. Great work, as always! :slight_smile:

Yes i do the same procedure :

Hi -
Can you post a simple file with which you can reproduce this behavior? Also, please run the Rhino SystemInfo command and copy-paste the result here.
-wim

Hello,
Sure, here is a new rhino8 file with only a few curves in it. The curves are on layer 04 that is in the collapsed layer 02 :
Curves_sellayer.3dm (66.1 KB)
Still the same problem occurs with the sellayer command.

And here is my SystemInfo :

Rhino 8 SR2 2023-12-12 (Rhino 8, 8.2.23346.13001, Git hash:master @ dbefe46c12cda06610a9ab683a211aa3d16f0030)
License type: Commercial, build 2023-12-12
License details: Cloud Zoo

Windows 11 (10.0.22621 SR0.0) or greater (Physical RAM: 32Gb)
.NET 7.0.0

Computer platform: LAPTOP  - Plugged in [99% battery remaining]

Hybrid graphics configuration.
  Primary display: Intel(R) Iris(R) Xe Graphics (Intel) Memory: 1GB, Driver date: 12-12-2022 (M-D-Y).
    > Integrated graphics device with 4 adapter port(s)
        - Windows Main Display is laptop's integrated screen or built-in port
  Primary OpenGL: NVIDIA GeForce RTX 3070 Ti Laptop GPU (NVidia) Memory: 8GB, Driver date: 12-6-2023 (M-D-Y). OpenGL Ver: 4.6.0 NVIDIA 546.33
    > Integrated accelerated graphics device with 4 adapter port(s)
        - Video pass-through to primary display device

OpenGL Settings
  Safe mode: Off
  Use accelerated hardware modes: On
  Redraw scene when viewports are exposed: On
  Graphics level being used: OpenGL 4.6 (primary GPU's maximum)
  
  Anti-alias mode: 8x
  Mip Map Filtering: Linear
  Anisotropic Filtering Mode: High
  
  Vendor Name: NVIDIA Corporation
  Render version: 4.6
  Shading Language: 4.60 NVIDIA
  Driver Date: 12-6-2023
  Driver Version: 31.0.15.4633
  Maximum Texture size: 32768 x 32768
  Z-Buffer depth: 24 bits
  Maximum Viewport size: 32768 x 32768
  Total Video Memory: 8 GB

Rhino plugins that do not ship with Rhino

Rhino plugins that ship with Rhino
  C:\Program Files\Rhino 8\Plug-ins\Commands.rhp	"Commands"	8.2.23346.13001
  C:\Program Files\Rhino 8\Plug-ins\rdk.rhp	"Renderer Development Kit"	
  C:\Program Files\Rhino 8\Plug-ins\RhinoRenderCycles.rhp	"Rhino Render"	8.2.23346.13001
  C:\Program Files\Rhino 8\Plug-ins\RhinoRender.rhp	"Legacy Rhino Render"	
  C:\Program Files\Rhino 8\Plug-ins\rdk_etoui.rhp	"RDK_EtoUI"	8.2.23346.13001
  C:\Program Files\Rhino 8\Plug-ins\NamedSnapshots.rhp	"Snapshots"	
  C:\Program Files\Rhino 8\Plug-ins\MeshCommands.rhp	"MeshCommands"	8.2.23346.13001
  C:\Program Files\Rhino 8\Plug-ins\RhinoCycles.rhp	"RhinoCycles"	8.2.23346.13001
  C:\Program Files\Rhino 8\Plug-ins\RhinoCode\RhinoCodePlugin.rhp	"RhinoCodePlugin"	8.2.23346.13001
  C:\Program Files\Rhino 8\Plug-ins\Toolbars\Toolbars.rhp	"Toolbars"	8.2.23346.13001
  C:\Program Files\Rhino 8\Plug-ins\3dxrhino.rhp	"3Dconnexion 3D Mouse"	
  C:\Program Files\Rhino 8\Plug-ins\Displacement.rhp	"Displacement"	
  C:\Program Files\Rhino 8\Plug-ins\SectionTools.rhp	"SectionTools"

If I run the SelLayer command on your file here in V8 (8.4SRC) and chose Layer 04 in the list, all the curves select. Maybe try updating to the current Service Release Candidate and see if that helps?

OK, I manually updated to 8.3. (Everything’s greyed out in the update tab in settings.)
Now sellayer command works again with preselected objects without moving the mouse !
Thanks a lot !
Sorry that it was just about an update… :sweat:

1 Like

if I run this script it asks to select an object…
I don’t know how it was supposed to work before,

However, It would be awesome to run the script (through an alias) and all the objects on the current layer get selected without any click.
or better to have a command in Rhino 9, any plan for this?

Yes, that is how it is supposed to work, as the request in the post title was to “select all objects on layer the selected object is on”. So at least one object must be selected in order to determine what layer(s) the objects to be selected are on. Preselection also works here.

If you are looking for a script that will select objects on the current layer - aside from the built-in function of right clicking in the layer box on the layer and choosing “Select objects” - I have this script:

SelCurrentLayerTree.py (626 Bytes)

which selects all objects on the current layer tree - i.e. also any objects on any sublayers of the current layer.

Here’s another one which just selects the objects on the current layer.

SelCurrentLayerObjs.py (500 Bytes)

2 Likes

Hi Matteo -

In addition to what Mitch provided, running SelLayer and then hitting Enter when the dialog pops up should do that.
-wim

Yep… but I also tried a macro: _Sellayer _Enter but that unfortunately does not work…

Did you mean -Sellayer?
But, yes … → RH-75788 SelLayer: Add Current option to command-line version
-wim

I use this macro:

-_SelLayer _Pick _Enter

Seems to work in R8 as well as in WIP. The object must be selected before running the macro, otherwise nothing happens.

Edit: Sorry, I got lost in the conversation, this solves the original question. Not selecting objects on Current layer.

Nope, it was because there was no Current option in -SelLayer that I tried without the dash, hoping that the OK button in the dialog would get pressed by the _Enter in the macro. But it doesn’t. So, yes, Current option in -SelLayer would be good.