Finding a python script in a subfolder

In the python editor, I have set a path to a folder located on my hard drive here that has all my python scripts. If I type -RunPythonScript ScriptName.py and there is a corresponding script by that name in that folder, it runs.

However, all of my scripts are in subfolders. In vb Rhinoscript, it manages to find scripts in subfolders, but in Python, it doesn’t. I would not like to have to add paths to all the individual sub folders (around 30-40) in the editor…

And… there doesn’t seem to be any kind of support for drag 'n’drop alias creation and script installation - or did I miss something?

And and… when is this all going to get integrated into the main Rhino options>Files>Search paths ?

Thanks,
–Mitch

1 Like

If you create a Python plug-in for Rhino, you can create an actual Rhino command instead of an alias to a script. These python plug-ins can be zipped into .ZIP files, renamed to .RHI, and installed and updated like other plug-ins. Looking around, I see that we never bothered to actually document this… maybe @stevebaer knows where to find the documentation for python plug-in creation and distribution.

1 Like

OK, always wondered how that worked, kind of an odd procedure, but I will try it, thanks.
I am most concerned with the subfolder issue though.

–Mitch

This is already supported using the . syntax. If you have a subdirectory in your path named ‘mitch’ and a file in that subdirectory called ‘coolscript.py’, you can execute it with

RunPythonScript mitch.coolscript

I’ve never been too sure that this should be integrated into that search path dialog. These lists of search paths are for two very different things, and there are also a bunch of other python options that I would rather keep together in a single place instead of strewing them about in several different locations.

OK, thanks Steve, that’s better than nothing, but it’s still not at the comfort level of its vb script counterpart that looks in subfolders without being told…

Cheers,
–Mitch

I understand that, but it’s confusing to the user to have to set up things in two different places and in the end I don’t think the user should need to worry if it’s a python script or vb script… My idea is that setting a path in Search paths should be valid for both.

–Mitch

Huh? I don’t understand why you consider the vb script version better. I’m willing to change things if they are for the better, but I just don’t get it. Please explain.
Thanks,
-Steve

I guess I could append the directories on the options dialog to the end of the python search paths.

I really don’t like the idea of having all of the python search path information on that dialog. I’m specifically thinking of the needed paths to the standard library and the rhinoscriptsyntax package. These probably should just be fixed anyway.

In the attached image below, you will see my “Rhinoscripts” folder, which is in my Dropbox (to keep my scripts synched between 3 work locations) there are 57 subfolders in there each with several/many scripts - probably more than 500 in all. The one file path set in search paths finds them all, if I type ! _-Runscript (scriptname) or create an alias with that, it finds and runs the script in any one of the subfolders.

My Python scripts folder (also in Dropbox) does not have as many subfolders or scripts yet, but someday it will… All I’m saying is it would be nice to be able to set a path to the main folder in the same dialog and have ! _-RunPythonScript (scriptname) find the script in one of the subfolders and run it…

–Mitch

What happens when you have two files with the same name, say

{dropbox}\Scripts\RhinoScripts\mitch\coolscript.rvb

{dropbox}\Scripts\RhinoScripts\steve\coolscript.rvb

?

I haven’t tested, but I know that either RhinoScript is going to report an error or just pick the first one it hits while digging through subfolders. The RunPythonScript technique is just more explicit.

If this is really a pain, I could add some option to the RunPythonScript command to perform a recursive subdirectory search, maybe by prefixing the script name with some special character(s)

I am always careful to give my scripts unique names… :smile:

I think it grabs the first one it finds…

Anyway, the impetus for starting this thread was not really management of my own script library, that sorta got mixed in there - it had to do with distributing scripts (specifically Python scripts) to others. For example, in another thread, I made a Python script for Heath, and got back the response

Thanks… never used a python script before. Is there some secret to
it?

Coming from an advanced user like Heath, this was a bit of a surprise. So then I went to try to make the installation as easy as possible and started to realize that for most inexperienced users, installing a python script is going to be somewhat more cumbersome than a vb script (which can be set up to drag and drop).

As most of my scripts are for distribution to users here or elsewhere in the community, my campaign here is simply to try to get the two on equal footing so that Python scripts can be handed out to anyone with the same ease as VB scripts can now. I would much rather be using Python to write new scripts.

Thanks,
–Mitch

Looks like we need to get the documentation and perhaps a script pulled together to make it easier to publish a python plugin. For end users it will be easier than RhinoScript, if a little harder for developers.

Brian, one missing bit that I see with Python plug-ins is a way for the user to know where the rhi file is putting the scripts- Say they want to remove it or something-- right now, I do not see how a user can do this without asking us or digging around quite a bit.

-Pascal

Yep, uninstall is on the RHI roadmap. But still, installing is much easier than the instructions that Mitch couldn’t quite write to get Heath to use a python script he wrote.

This sounds very interesting. Any news on where to find official documentation? Or a basic example?

Is this what you are looking for?