I’m not sure this is any better than the post I just deleted but here it goes …
Your scripts can reside anywhere but if they are not on the search path they can’t be imported by other scripts.
One current limitation is that the python search path is not configurable. That means you can’t import modules that are not under: /Users/NAME/Library/Application\ Support/McNeel/Rhinoceros/Scripts
or not in the directory or a subdirectory of the file you’re currently running. Subdirectories need to have a __init__.py
file so they are recognised as modules.
Let’s say your working directory is ~/py
. ex:
cd ~/py
mkdir mylib
cd mylib
touch __init__.py # create empty file
echo "def doit(): print 'doit'" >> myscript.py #simple script
you can now import your module from a script that’s in ~/py
. Ex:
import mylib.myscript as s
s.doit()
If your library is in a directory that is not under a search path you can create a link to it from /Users/NAME/Library/Application\ Support/McNeel/Rhinoceros/Scripts
. If in the previous example the mylib
directory is somewhere that’s not on the path you’d do something like this:
mkdir /somepath/mylib
cd ~/Library/Application\ Support/McNeel/Rhinoceros/Scripts
ln -s /somepath/mylib mylib # link
The example script:
import mylib.myscript as s
s.doit()
would still work.
Being able to configure the search path is important and we’ll add it sooner than later but in the meantime I hope this workaround is useful.
Alain