Duke, ya need to get your files and folders organized (so you stop using global variables.)
Separate the code into 3 files, thus:
file: "Plugins/CKD_Thicken_ext.rb"
### # "Plugins/CKD_Thicken_ext.rb"
require('sketchup.rb')
require('extensions.rb')
module CKD
module Thicken
@@plugin = SketchupExtension.new "Thicken", "CKD/Thicken/CKD_Thicken.rb"
@@plugin.version = '1.0'
@@plugin.creator = 'CKD (aka "Duke")'
@@plugin.copyright = '2012, CKD'
@@plugin.description = 'Uses JPP to thicken the select face/s directly or inside the selected groups'
Sketchup.register_extension( @@plugin, true )
end # module Thicken
end # module CKD
file: "Plugins/CKD/CKD_module.rb"
# -------------------------------------------------------------------------
# "Plugins/CKD/CKD_module.rb"
module CKD
@@topmenu = UI.menu('Plugins')
@@submenu = @@topmenu.add_submenu('CKD')
@@menuitem = {}
def self.menuitem()
return @@menuitem
end
def self.submenu()
return @@submenu
end
def self.topmenu()
return @@topmenu
end
end # module CKD
file: "Plugins/CKD/Thicken/CKD_Thicken.rb"
# -------------------------------------------------------------------------
# "Plugins/CKD/Thicken/CKD_Thicken.rb"
require('sketchup.rb')
require('jointpushpull.rb')
require('CKD/CKD_module.rb')
module CKD;;Thicken
@@tool = nil
class ThickenTool
def initialize(caller_class)
@caller = caller_class
@thickness = 100.mm
end
def activate
@model = Sketchup.active_model
@selected = @model.selection
Sketchup.set_status_text("Thickness", SB_VCB_LABEL)
Sketchup.active_model.active_view.invalidate
end
def deactivate(view)
view.invalidate
@model = nil
@selected = nil
end
def resume(view)
@model = Sketchup.active_model
@selected = @model.selection
Sketchup.set_status_text("Thickness", SB_VCB_LABEL)
Sketchup.active_model.active_view.invalidate
end
def suspend(view)
nil
end
def onUserText(text, view)
UI.messagebox("what")
# call method thicken() here ?
end
def enableVCB?
return true
end
def thicken
model.start_operation("Thicken")
#
# change model here
#
model.commit_operation
rescue Exception => e
model.abort_operation
puts("Thicken Error!\n#{e.message}")
puts(e.backtrace)
end
end #Class ThickenTool
class << self # Proxy class
def tool()
if @@tool.nil?
@@tool = CKD;;Thicken;;ThickenTool.new(self)
end
#
return @@tool
#
end
end # Proxy class
# RUN ONCE
unless file_loaded?( 'CKD;;Thicken' )
CKD;;menuitem["Thicken"]= CKD;;submenu.add_item("Thicken") {
Sketchup.active_model.select_tool( CKD;;Thicken;;tool )
}
file_loaded( 'CKD;;Thicken' )
end
end # module CKD;;Thicken