Review of Plugin/NameSpace/Extension Format
-
Several months ago I asked about plugin formating and Dan made a namespace template/example for me and now I have finally got a working plugin written using the template. I thought before I offered it to fellow woodworkers I would post it here for comments to see if I am using acceptable format so as not to cause problems with other plugins.
Thanks for your help
Keith
-
You're .rb file attached doesn't tell us anything about your namespacing. It refers to other files we cannot see.
-
I edited my post with the correct file. You can either install as extension or change it to a zip file and unzip to see the files in question.
Keith
-
A minor change needed ...
in file: "K2WS_Comp2LayerScene_ext.rb", lines 7 & 8 should not be at this place, in this file.
(Because it will force a load of the "K2WS/k2ws_module.rb" file even when the user has turned OFF the plugin, via the Preferences dialog (Extensions panel.)Move those two lines, into the "K2WS/Comp2LayerScene/Comp2LayerScene.rb" file, just after (current) line 22, which is:
require('sketchup.rb')
This way.. it will only load, when the plugin is turned ON. (Many users are also developers, and they need to have the option of a "clean" and fast loading Ruby environment when testing/debugging.)
The only other thing, is that if you need to get a reference "handle" on your plugin's
SketchupExtension
instance object, you cannot do it under SU7.x, unless you save it as a module var. This means wrapping the definition in file: "K2WS_Comp2LayerScene_ext.rb" within your plugin namespace. (Note that in SU 8.0M2 or higher, you can query theExtensionsManager
collection to find a certainSketchupExtension
instance, if need be, but since you are creating it, you might as well retain a reference to it.)Ex: "K2WS_Comp2LayerScene_ext.rb"
# Load the normal support files. require('sketchup.rb') require('extensions.rb') module K²WS; end module K²WS;;Comp2LayerScene # Create the extension. ext = SketchupExtension.new('K2WS (Component to Layer & Scene)', 'K2WS/Comp2LayerScene/Comp2LayerScene_loader.rb') # Keep a reference to it; @@plugin = ext # Attach some nice info. ext.creator = 'Keith Krueger email kbkrueger2@gmail.com' ext.version = '1.0.0' ext.description = 'Layers & Scenes for Components & Dim' ext.copyright = '' # Register and load the extension on startup. Sketchup.register_extension(ext, true) end # module K²WS;;Comp2LayerScene
Also, would suggest putting something in the "
copyright
" attribute, to indicate the "Terms of Use": eaxmples: "(c)2012, Keith Krueger, All Rights Reserved", or "released under the Artistic License, 2.0", or "see GPL, version X.x", or "Public Domain" or ... whatever you decide.
Note that future versions of Ruby will require that all method calls have parameter lists delimted by
(
and)
, so try to get in the habit of using them now. Especially if you do not want to have to go back through your old projects, and add them in later, when SketchUp begins using one of these newer Ruby versions. -
Thanks Dan for the review and changes. I have adjusted my files to include your suggestions and when I have a how to vidio completed I will post in the plugin section.
Also I expect to be back for help on putting my Joint Tools under the namespace umbrella as I have just started that process.
Keith
Advertisement