Combining a plgn that uses a class for the def w/other plgns
-
I was queuing up a list of scripts to run sequentially as a ruby plug in. Easy enough...
require "plugin_name.rb"
and then thedef
from that plugin I want to run.I added three plugins and the script runs great. The problem came when I started to add the fourth. There are two problems with it...
- the plugin runs on a button click in the Sketchup UI and the plugin is actually in another folder within the plugin folder
- instead of a regular
def
it introduces a class... "SwivelButton" and from then on calls on that class + what I guess is a variable or extension as thedef
. i.e.def SwivelButton::init()
;def SwivelButton::getIndexFilePath()
; etc.
So, I don't know what do exactly. I thought calling on the first one
SwivelButton::init()
would be the way to go but as it doesn't start with a lowercase letter it didn't work at all. I tried doing a find and replace to exchange the "S" with an "s" but that ended horribly. Any suggestions? This is google's web exporter plugin by the way. -
Whenever you want to know how to activate a certain plugin programmatically, look for the place where it adds a tool-bar button or menu item. Here is the code in this particular plugin that does that (it starts on line 56 in my <Plugins dir>/swivelButtonPlugin/swivelButton.rb):
` cmd = UI::Command.new(@@title) {handleToolbarButtonPress()}
cmd.small_icon = tempImgDirectory + "/swivelButtontb.png"
cmd.large_icon = tempImgDirectory + "/swivelButtontb.png"
cmd.status_bar_text = cmd.tooltip = "Create a set of images orbiting a model"
cmd.menu_text = @@title
swivelToolbar = UI::Toolbar.new(@@title)
swivelToolbar.add_item(cmd)
swivelToolbar.showUI::menu('Tools').add_item(cmd);`
As you can see, the menu and tool-bar button both refer to a UI::Command object whose command is "handleToolbarButtonPress()". By calling this method in your code, it will have the same effect as someone manually choosing the button or menu item.
Remember: Follow the mon... menu!
-
Thank you. You know in hind sight that makes perfect sense. I guess the whole class in the def thing just though me. I am definitely not a programmer so when I see something I'm not used to seeing it throws me off. Thanks again
Advertisement