Hi everyone!
I’m just getting started with the SketchUp Ruby API and decided to create a quick plugin to experiment with a couple of things.
I followed the official Github examples and currently have 2 files in the Plugins folder: the plugin registration file (which is pretty much boilerplate) along with another file that lives in a subdirectory. The content of the latter is as follows:
require 'sketchup.rb'
module CMExtension
module Tool
class Reconstruction
def activate
puts "Hi there!"
end
end
def self.activate_tool
Sketchup.active_model.select_tool(Reconstruction.new)
end
unless file_loaded?(__FILE__)
menu = UI.menu('Plugins')
menu.add_item('Reconstruction') {
self.activate_tool
}
file_loaded(__FILE__)
end
end # module Tool
end # module CMExtension
This gives me a new button under the “Extensions” menu, however, after I click the said button any tool that was previously selected from the toolbar (like “Select” or “Dimension Tool”) doesn’t respond to click events unless I select a different tool. The Hi there
message shows up in the Ruby console as expected.
I believe that my Reconstruction
class is missing a handler of some sort that would bring the focus back to whatever was selected previously. Any ideas on how to achieve that?
Thanks in advance!