amaraa
(Amaraa)
April 20, 2022, 8:14am
1
Hello,
I’m trying to make a very small script that selects objects based on their layer name in python.
import rhinoscriptsyntax as rs
if run is True:
rs.ObjectsByLayer(layer_name, select=False)
x = layer_name
I thought it would be pretty straightforward but I am very confused right now.
I’d appreciate if you point out any mistakes here.
Thank you.
curves.3dm (24.9 KB)
selectobjectbylayername.gh (4.5 KB)
menno
(Menno Deij - van Rijswijk)
April 20, 2022, 8:57am
2
Have you tried select=True
, it seems that is needed to select the objects?
And also, the variable ‘layer_name’ is not defined at all it seems.
menno
(Menno Deij - van Rijswijk)
April 20, 2022, 9:02am
3
There were a few other problems, but this seems to work
import rhinoscriptsyntax as rs
import scriptcontext as sc
import Rhino
sc.doc = Rhino.RhinoDoc.ActiveDoc
layer_name = x
if run is True:
rs.ObjectsByLayer(layer_name, select=True)
sc.doc = ghdoc
1 Like
amaraa
(Amaraa)
April 20, 2022, 1:09pm
4
Thank you very much @menno sir.
It was a good lesson regarding ActiveDoc
command.
Indeed, it works very well now.
Have a great day!
Kind regards,
Amaraa.