sketchucation logo sketchucation
    • Login
    πŸ€‘ SketchPlus 1.3 | 44 Tools for $15 until June 20th Buy Now

    Command lne for loading a plugin from an external folder

    Scheduled Pinned Locked Moved Plugins
    7 Posts 3 Posters 1.1k Views 3 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.
    • masterpaulM Offline
      masterpaul
      last edited by

      Hey guys Im un Uni and I cant install plugins in the sketchup folder. Is there a Command lne for loading a plugin from an external folder that I could type in ruby?

      Thank you

      1 Reply Last reply Reply Quote 0
      • Dave RD Offline
        Dave R
        last edited by

        I moved this post because it has nothing to do with LayOut which is where it was originally posted.

        Try

        load"plugin path\plugin.rb"
        

        Etaoin Shrdlu

        %

        (THERE'S NO PLACE LIKE)

        G28 X0.0 Y0.0 Z0.0

        M30

        %

        1 Reply Last reply Reply Quote 0
        • masterpaulM Offline
          masterpaul
          last edited by

          @dave r said:

          I moved this post because it has nothing to do with LayOut which is where it was originally posted.

          Try

          load"plugin path/plugin.rb"
          

          Sorry about posting it in layout.
          So lets say lets say I want to load push pull I would write:

          load"E:\Sketchup\Plugins/jointpushpull.rb" ?

          And if the plugin was dependent on other plugins would there be a way of loading the whole foldier?

          1 Reply Last reply Reply Quote 0
          • TIGT Offline
            TIG Moderator
            last edited by

            Let's assume that you want to load files from "H:/Sketchup/Plugins".
            You can append that folder-path to the system list that Sketchup uses to load from without you needing to pass a full load path.
            So in the Ruby Console type
            $LOAD_PATH << "H:/Sketchup/Plugins";$LOAD_PATH.uniq!
            You need to do this every session of Sketchup.

            Now any ruby file you want to load from that folder can be called thus
            load "paulswondertool.rb" and it will load/reload that code.

            Note that depending on how they are written some tools will not reload, most tools use file_loaded? to stop multiple menus on a reload, so again menu changes might not be seen on a reload.

            Scripts that use __FILE__ to find themselves and thereby their supporting folders/files will work if everything is in "H:/Sketchup/Plugins" in the correct relationship, BUT some older tools using Sketchup.find_support_file... syntax might fail as they will look in Plugins and therefore not find stuff...
            Also the v8M2 .rbz archive installer won't work as it looks for the Plugins folder too - if you have a .rbz archive change its suffix to .zip, extract the files and subfolders and put them into "H:/Sketchup/Plugins" instead, with any luck they'll work because most complex scripts use __FILE__ to find where they are.

            If you want to load one file quickly and not set yourself up for multiple loadings then a simple
            load "H:/Sketchup/Plugins/paulswondertool.rb" will work for that one file [it doesn't even need the .rb suffix, BUT it's always best to do it in case there are conflicting file names otherwise].
            Note that any .rb/.rbs files auto-load from Plugins or Tools folders [or other folders in the $LOAD_PATH when Sketchup starts***], but other files don't, so if you do have access to such a folder then renaming a file as .rb! or .txt disables it, BUT it can be loaded manually by specifying
            the full path like load "H:/Skechup/Plugins/paulswondertool.rb!".

            ***When I was teaching Sketchup/Ruby at a local Uni they had the same problems. There I got the IT guys to add a short .rb script into their secure Sketchup/Plugins folder, not accessible by students. This added the student's mapped home-path to the $LOAD_PATH as "H:/Sketchup_Plugins" so that it then loaded their scripts at startup and was accessible for edited files later as set out earlier...
            Here's a version of the script - it'll probably need adjusting to suit your drive setups etc...

            PS: When writing filepaths use / as the separator.
            This will work inside either '' or "".
            BUT if you use a \ it must be inside '', OR inside "" all \ separators must be escaped - so it's 'C:\Temp' OR "C:\Temp"' or C:/Temp' OR "C:/Temp"


            ZZ_LoadPathUpdater.rb

            TIG

            1 Reply Last reply Reply Quote 0
            • masterpaulM Offline
              masterpaul
              last edited by

              Thank you I understood how to load a single plugin, and did so successfully but not so much a whole file from this directory: E:\Sketchup\Plugins

              1 Reply Last reply Reply Quote 0
              • TIGT Offline
                TIG Moderator
                last edited by

                @masterpaul said:

                Thank you I understood how to load a single plugin, and did so successfully but not so much a whole file from this directory: E:\Sketchup\Plugins
                Inside my example script the last few lines of code load everything inside a given folder. You can't type multi-line code in the console, use ; to make it one line...
                First set the path
                path='E:\Sketchup\Plugins'
                then
                Dir.entries(path).each{|file|ext=File.extname(file).downcase;next unless ext==".rb"||ext==".rbs";Sketchup.load(File.join(path, file))}
                To load all files inside the give 'path'...

                TIG

                1 Reply Last reply Reply Quote 0
                • masterpaulM Offline
                  masterpaul
                  last edited by

                  @tig said:

                  @masterpaul said:

                  Thank you I understood how to load a single plugin, and did so successfully but not so much a whole file from this directory: E:\Sketchup\Plugins
                  Inside my example script the last few lines of code load everything inside a given folder. You can't type multi-line code in the console, use ; to make it one line...
                  First set the path
                  path='E:\Sketchup\Plugins'
                  then
                  Dir.entries(path).each{|file|ext=File.extname(file).downcase;next unless ext==".rb"||ext==".rbs";Sketchup.load(File.join(path, file))}
                  To load all files inside the give 'path'...

                  Ah thankyou.. it works perfectly πŸ˜„

                  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