Redefine class in rhinoscript


I would like to use classes in VB scripting.

This works fine if you run the code that contains the class definition only once.
The second time it gives the error “Name redefined”

That should not be such a problem when the program is finished, but during programming
and debugging, it would be handy if a class could be redefined without having to restart rhinoceros.

Is there a way to do this?



From the RhinoScript help file:

All script subroutines, functions, classes and global variables that are loaded into the loaded into the memory of the VBScript interpreter will remain in memory for the duration of the modeling session, unless the “Reinitialize script engine when opening new models” scripting option is enabled. This can be problematic when developing scripts that declare global constants or class definitions for these types of expressions can only be loaded once during a scripting session. When you try load a script that contains these types of declarations, you will receive a “Name redefined” VBScript runtime error.

To work around this limitation, you can simply open a new model if the “Reinitialize script engine when opening new models” scripting option is enabled. But, opening new models is not always a practical solution.

You can also run the ResetRhinoScript command. Note, when either one of these techniques is used, all script subroutines, functions, classes and variables loaded during the scripting session will be erased.

Note, the ResetRhinoScript command should only be used during the development and debugging of scripts. It should not be used a method for cleaning up after scripts for this command will erase all scripting data, not just your scripting data. Also, this command does not auto-complete on the Rhino command line.

Thanks a lot!

Hi Miguel,

I am making researches on how to deal with multiple scripts talking to each other in VBscript.

This implies declaring global variables with the first script, and then change this variables with following scripts…

To my knowledge I have no proper documentation on this, since Rhinoscript 101 manual dos not adress this issue.

Do you have any good suggestion on how to do this ?


Hello Tanguy,

You can use the sticky dictionary to store global variables and share them between scripts.


Hello Graham,

Do you mean using a dictionnary like explaines here ?

In my case I use nested arrays, because of my data structure, and I amvery happy with it. For instance I am storing all the points of my building in an array (arrPoints), such that the point j of structural element i is arrPoints(i)(j).

My script reads texte files and finally draws alll points (and meshes), about 1 million of points.

What I want to do is just store this array (arrPoint). From what I hear from @Helvetosaur I can just write, out of all functions
Private arrPoints()

I am referring here to Helvetosaur example here :

Can I then use this array in other scripts (during the same rhino session) ?


No I was thinking of the sticky dictionary described here : but it looks like that may not be available with RhinoScript, only with Python / C#