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

    Loading plugins only when needed

    Scheduled Pinned Locked Moved Plugins
    6 Posts 5 Posters 421 Views 5 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.
    • K Offline
      ktkoh
      last edited by

      After writing the Mortise & Tenon plugin I realized it could be the basis for other woodworking furniture joints ie. Dowels, Dovetails, Biscuits, etc. When starting to develop these additions it became useful to think of each program individually as this should make the logic and program easier to develop and follow. Then I thought that adding detail to joints in a sketchup furniture design is a very small part of what needs to be done and I didn't want these plugins taking up resources when not needed. So I devised a method of using a loading script that only populates the menu but waits for the first use to load the plugin. It seems to work well but I thought I would post the example to see if there are hidden problems I have not encountered or thought out. The included files are:"loadK2WS_Tools.rb" placed in the plugins directory to automatically load other files, "KK_MortiseTool_X.rb" this is the actual tool script, and "Test_MortiseTool2.rb" the file that creates the menu items and loads the tool plugin as needed (these files need to be placed in a K2WS_Tools directory in the plugins directory ). Note: as written only the Tenon and Mortise tools are available the M&T_Joint and LT_Joints do not function until the tool script is loaded the first time by the Tenon or Mortise tools. This was done to demonstrate that the main tool script file did not load until requested.

      Thanks for looking (comments +/- appreciated)
      Keith


      loadK2WS_Tools.rb


      KK_MortiseTool_X.rb


      Test_MortiseTool2.rb

      1 Reply Last reply Reply Quote 0
      • thomthomT Offline
        thomthom
        last edited by

        So "loading plugins only when needed" - is not for all plugins? Just for Mortise & Tenon?
        ❓

        Thomas Thomassen — SketchUp Monkey & Coding addict
        List of my plugins and link to the CookieWare fund

        1 Reply Last reply Reply Quote 0
        • srxS Offline
          srx
          last edited by

          Well it would be very good plugin if it was for all.

          www.saurus.rs

          1 Reply Last reply Reply Quote 0
          • J Offline
            Jim
            last edited by

            Seems like a good idea. But wouldn't you instead have a long list of available plugins, instead of a long list of loaded plugins?

            Hi

            1 Reply Last reply Reply Quote 0
            • K Offline
              ktkoh
              last edited by

              The concept is usable on any plugin however the file loading and menu would need to be separated into a separate plugin. Yes it would be nice to have a list and load from a list but so far that has seemed to evaded the plugin writers. The way I made this the menu for the tool will exist which I think is handy for the user but only load as needed. I mainly put this out for comments and possibly starting some thinking on a different approach to the management problem. Also I wanted to know if there were any problems obvious to others that I overlooked as I am rather a newbe to SkethcUp & Ruby programing.

              Keith

              1 Reply Last reply Reply Quote 0
              • fredo6F Offline
                fredo6
                last edited by

                Keith,

                I think this is the way to do, because it speeds up the start of the Sketchup application.

                I introduced this approach for my own plugins with LibFredo6 3.6. I called it "two-phase loading" (only the files bootstrap_... are loaded at SU startup time). Actually, you may see a small message in the status bar indicating the file loading the first time you use the plugin. Also the time for the second phase is indicated in the About... box.

                I use a slightly different method but it does not matter.

                This save a few hundreds milliseconds for each plugin, so seconds at the end

                Fredo

                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