Redefine class in rhinoscript


#1

Hello,

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?

Thanks,

Miguel


(Dale Fugier) #2

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.


#3

Thanks a lot!