Command lne for loading a plugin from an external folder
-
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
-
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"
-
@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?
-
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 usingSketchup.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 likeload "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"
-
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
-
@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 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
Advertisement