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 the
ExtensionsManager collection to find a certain
SketchupExtension instance, if need be, but since you are creating it, you might as well retain a reference to it.)
Ex: "
K2WS_Comp2LayerScene_ext.rb"
- Code: Select all
# 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.