Ruby API and Ruby classes
-
Hello everyone,
i working on a sketchup plugin and i want to ask you, is it obligatory to have the entire program in one .rb file or is it possible to have a plugin with muliple classes ?
For example class House, class Type ... and each class will contain methodes that will be used in one plugin.
so is it possible to do so ? if yes how ?
thnx in advance.
-
It is entirely permissible and pretty common to devote one file to each class. However, if you do so you will need to put your files into your own subfolder of Plugins, because otherwise SketchUp will try to load all of the individual .rb files as it starts up, which is not what you need. Instead, you should have a master file that loads/requires the others as and when needed. Also, you should look into the SketchUpExtension class, as it provides a natural way to manage your code in SketchUp. And, above all, you should wrap all of your code inside your own personal module to prevent it from clashing with other plugins and extensions.
Advertisement