sketchucation logo sketchucation
    • Login
    ℹ️ Licensed Extensions | FredoBatch, ElevationProfile, FredoSketch, LayOps, MatSim and Pic2Shape will require license from Sept 1st More Info

    Combining a plgn that uses a class for the def w/other plgns

    Scheduled Pinned Locked Moved Developers' Forum
    3 Posts 2 Posters 152 Views 2 Watching
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • E Offline
      Eric_Erb
      last edited by

      I was queuing up a list of scripts to run sequentially as a ruby plug in. Easy enough...

      require "plugin_name.rb" and then the def 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...

      1. the plugin runs on a button click in the Sketchup UI and the plugin is actually in another folder within the plugin folder
      2. 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 the def. 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.

      1 Reply Last reply Reply Quote 0
      • RunnerPackR Offline
        RunnerPack
        last edited by

        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.show

        UI::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! 😉

        You might have noticed... I'm a bit of a ferpectionist.

        1 Reply Last reply Reply Quote 0
        • E Offline
          Eric_Erb
          last edited by

          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

          1 Reply Last reply Reply Quote 0
          • 1 / 1
          • First post
            Last post
          Buy SketchPlus
          Buy SUbD
          Buy WrapR
          Buy eBook
          Buy Modelur
          Buy Vertex Tools
          Buy SketchCuisine
          Buy FormFonts

          Advertisement