Hi Pascal,
When running the script from the editor, it works.
I currently have this and have updated the directory to monitor for scripts.
So it’s possibly something with the command macro when I press F2?
-Jeremy
Hi Pascal,
When running the script from the editor, it works.
I currently have this and have updated the directory to monitor for scripts.
So it’s possibly something with the command macro when I press F2?
-Jeremy
Try removing the
if name =="main":
HighlightLayers()
and simply put
HighlightLayers()
– No indent ! –
Let us know if that works better.
Hi Helvetosaur,
with this in the python editor:
import scriptcontext as sc
import rhinoscriptsyntax as rs
def HighlightLayers():
ids = rs.SelectedObjects()
if not ids:return
layers = [rs.ObjectLayer(id) for id in ids]
layers = list(set(layers))
for layer in layers:
parent = rs.ParentLayer(layer)
while parent is not None:
rs.ExpandLayer(parent, True)
parent = rs.ParentLayer(parent)
layers = [sc.doc.Layers.FindByFullPath(layer, -1) for layer in layers]
sc.doc.Layers.Select(layers, True)
HighlightLayers()
It works when pressing play, but not when running the shortcut leading to that file.
!_-RunPythonScript “TestFile”
Giving this error message
As I am very much out of my depth with scripting, it’s probably user error somewhere…
CHeers,
Jeremy
“Testfile.py” is stored where? If you want to run the script with a macro like that, you first need to set a path to the folder where the script is stored inside the Python editor, otherwise the script will not be found.
To set the path, in the Python editor, go to Tools>Options and set a path to the folder where your scripts are stored.
If you do not want to do that, then your macro must include the full path to the file, not just the file name.
i.e. if the script file is on your desktop:
!_-RunPythonScript "C:\Users\your_username\Desktop\TestFile.py"
Hi Helvetosaur,
is the custom folder
with
And these are the paths set in the folder search menu item:
In rhino 6 with its respective appdata path, it works without the .py extension.
I have managed to make it work in rhino 7 now by using the full path/filename as you said.
Perhaps it’s something to do with the folder monitoring.
Regards,
Jeremy
Hmm, so if it’s saved on your desktop, as you have a path set in the editor to that -
!_-RunPythonScript "TestFile.py"
still does not work?
Yep, still no luck with the file on the desktop. When running with the .py suffix, there is no error message, but the macro does not successfully complete
^ is what appears in the command line
Without the suffix, and with the path monitoring the desktop, this error persists
-Jeremy
Hi Jeremy - the file search paths in Options > Files are for textures in rendering materials, I do not think they will help find script - I have not specifically tested that. To set python search paths, open the Python script editor (EditPythonScript
) and in the Tools> Options > Files menu there set your search path.
-Pascal
Good catch…! I did not look closely enough at the image posted above withe the file paths set, I assumed it was a screenshot of the Python editor…
I did specify in my post above
but I guess it didn’t register.
Thanks for pointing this out Pascal.
As I suspected, I had made a mistake somewhere, and this was it.
Now I have directed to the sub-path ‘User python scripts’, the hotkey works as it did in rhino 6.
Cheers to both you and Helvetosaur
Can you show me how to do it, thanks
can you add the script (Select Object) to the script, if yes it would be greatHighlightLayers.py (683 Bytes)
I want the object to add to the script
[image]
Can you try to attach your image again? I don’t understand what you are asking for apparently.
Thanks,
Dan
I WANT WHEN IMPORTING THE CLASS IT IS AUTOMATICALLY SELECTED, AUDIENCEVideo_2021-09-18_002057.rar (4.5 MB)
So if I understand correctly you want to select an object, highlight it in the layer pane and select everything else on that layer. Is that correct?
exactly as i wanted
very good thank you