No, I meant in the Python editor itself… But now, rereading the whole thread I’m not sure whether you’re looking for a way to set file paths (what I showed) or a way to run startup scripts. As far as I know the only way to run Python scripts at startup currently is in Options>General to set them as startup commands with
! _-RunPythonScript scriptfilename.py
and have previously set a path to the folder where the script is in the Python editor as above, or have the full pathname in the command.
Just trying to have all the stuff in the same place so it’s easier to find for the user, it seems odd to be able to set paths to where Rhinoscript can find files in Rhino options, and not be able to do the same thing with Python scripts.
I’m pretty confused about this thread. There seem to be about three different topics being discussed.
With respect to python
1 - Why do you want to run a python script when starting Rhino? Does anyone have an example of why they would want to do this? Does “-RunPythonScript myscript.py” work for people? I’m just confused and need help.
2 - I can see the confusion about python not looking in the folders specified by the “Rhino Search Paths”. I can change this for Rhino 6 and see if that makes more sense for users (thanks.)
I opened that issue at github. Sorry for duplicating it with already present ones.
There is no specific reason, at least from my side. I just wanted to run some small script which will add text string to the document, then explode it to curves. Like “Merry Christmas” or something similar. Just a play-around really.
Adding the folder where Rhino startup .py is located to the “Module Search Paths” (inside of Rhino Python Editor) and then adding the name of that specific Rhino startup .py to Rhino Command list (_-RunPythonScript “startup.py”) worked perfectly.
I also checked the option with supplying the full path, instead of adding the folder location to “Module Searc Paths” - it worked too.
Just like Mitch explained.
Pascal is this something that can be called outside of Rhino?
I would like to run a startup script that populates the user’s Grasshopper template directory field with a server location. This way the user would always have the latest Grasshopper template upon starting Rhino.
The reason I’d like to call this outside of Rhino is so that the script is automatically referenced within the Rhino Options > RhinoScript > Startup field upon the user’s installation of Rhino.
If I can’t let me know what you suggest, for example I could make a toolbar button using Rhino.AddStartupScript() to take care of this.
Could someone walk me down the process of adding a python script to rhino (loading it at startup) and then assigning a shortcut to the said python script. I mean, is this possible with Rhino 5 (for windows)? I’m aware there is a wish/effort to combine .rvb and .py scripts at start-up in rhino 6 but I was just curious, thanks. Or a relevant blog post would be very useful as well. Thank you, noob out.
Mitch, thanks for the prompt response. One more thing to clear, does this process load the script to be recalled later during the session and attach aliases to it? I’m doubtful but hopeful anyhow my follow-up question is if you have these scripts in .rvb format then? Thank you!
It’s not all that hard… Yes, it would be easier to drag and drop, but having set a path to the scripts folder (once) in the editor, all you need to do is throw the script file into that folder and then make your alias.
Dim intCount, arrPaths, strPath
intCount = Rhino.StartupScriptCount
If intCount > 0 Then
arrPaths = Rhino.StartupScriptList
For Each strPath In arrPaths
Dim fso, f, f1, fc, s
Set fso = CreateObject("Scripting.FileSystemObject")
Set f = fso.GetFolder("PATH\TO\MY\OTHER\FOLDER\FULL\OF\SCRIPTS")
Set fc = f.Files
For Each f1 In fc
s = f & "\" & f1.name