How to create a function library in Rhino


I am working on an optimization project where I want to optimize various ship hulls. I have created different functions named:


I have also created some other handy functions, such as MirrorHull(), TranslateHull() etc. However, having all these functions in one script file makes the file very large and unreadable. How do I separate each function or a group of functions to a separate file? Keeping them in the same directory is not working like in Matlab.

Thanks for help,


Hi Amitava,

Are you using python or VB to create your functions? Using python you can save all your functions in a library and load as needed. I’m not sure about doing the same thing in VB though.

I am using Rhinoscript (or VB Script). Most tutorials are specific to one problem where everything is in one single file. In my case, it’s getting too long.

Hi Amitava,
you can save each Function or Subroutine in a separate file. Once loaded you can Call it from any other script.
Or do you want to compile your scripts to a plug-in? If so which compiler do you use?

Hi @Jess,

What do you mean by

Once loaded you can Call it from any other script

Are you suggesting, when I open Rhino, I open each function files and press F5 key so they get loaded in Rhino’s memory?

Hi Amitava, looks like you are running your scripts from the ScriptEditor. That’s fine during development but there are many more possibilities. However, the general concept of loading and running scripts is well explained here:

If you have more questions feel free to ask.

Edit: I’ll add some info:
Have a look at the ScriptEditor: There are two scripts Main and HelloRhino. HelloRhino contains a Subroutine named PrintHelloRhino. Once you have loaded that script the Subroutine is in the memory of the scriptengine. That means you can call it from any other script (like demonstrated in Main.rvb). You can also run it from the _RunScript Command which lists all loaded Subroutines (but not Functions).

Thank you again @Jess. Now I understand how I can separate my functions and load them when Rhino starts.

Hi Jess, if i want to compile my scripts in a plugin, and compile it with Rhino Script Compiler, how can i do?

Resuming: i have the same functions in different scripts, i want to put these functions in one script file…

1 - how to call the function between the scripts?
2 - how to compile everything in one plugin?


Hi @mconti
I have not used vbscripts for a while, but I think this should still work: Load your common functions rvb-file with the script compiler. Then enter the index of the automatically created command and edit the type. Change the type from command to Library. Then you should be able to access your functions from all other vb-scripts.