# # Name : PluginLoader # Description : Adds a helper submenu to the plugin menu to offer these # functions: # - Load single plugin or load all plugins in a folder # - Go to weblinks for plugin collections # - Go to weblinks for Ruby resources # Usage : The web links are self-explanatory. All will open in an # external (system standard) browser. For the plugin loading # functions it is important to note that plugin files have a RB # extension. # # Author : Alexander Schreyer, www.alexschreyer.net # E-Mail: mail@alexschreyer.net # Date : March 9, 2009 # Type : Tool # Disclaimer: THIS SOFTWARE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR # IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR # PURPOSE. # # Website: http://www.alexschreyer.net/projects/plugin-loader-for-sketchup/ # # Credits: Jim Folz for his help (in the SCF) and for # contributing the require_all function. # # History: 1.0 (3/9/2009) - first version # 1.1 (3/18/2009) - Changes: # - Added more plugin links and fixed some spelling # - Added browser "buttons" and better explanation # - Added help menu item and updated helpfile # - Changed menu order a bit # # To-Do List: - Would be nice to open the plugin collections in a web dialog # and then allow the user to download and install the plugin # with one click. # - Should I add more web links? # - Folder selection is a bit workaroundish. A standard # directory picker would be better. # require 'sketchup.rb' def as_load_plugin_file # UI.messagebox "Depending on a plugin's programmed dependecies, it may not be possible to load it using this tool.\nPlease make sure all required files are in the same directory." initdir = Sketchup.find_support_file("plugins") if Sketchup.version_number < 7000000 filename = UI.openpanel "Select a SketchUp Ruby plugin file (with RB extension) to load it" else filename = UI.openpanel "Select a SketchUp Ruby plugin file (with RB extension) to load it", initdir, "*.rb" end # UI.messagebox filename.gsub("\\", "/") load filename end # as_load_plugin_file def as_require_all(dirname) # Code by Jim Folz begin rbfiles = Dir[File.join(dirname, "*.rb")] $:.push dirname rbfiles.each {|f| require f} rescue puts "could not load files from #{dirname}" end end # as_require_all def as_load_plugin_folder UI.messagebox "Select any file in the folder where you would like to load all available ruby plugins." initdir = Sketchup.find_support_file("plugins") if Sketchup.version_number < 7000000 filename = UI.openpanel "Select any file - all plugins will be loaded from that folder" else filename = UI.openpanel "Select any file - all plugins will be loaded from that folder", initdir, "*.rb" end foldername = File.dirname(filename) as_require_all(foldername) # require_all(File.join(Sketchup.find_support_file("plugins"),"inactive")) # How can we select a folder easily with Ruby??? end # as_load_plugin_folder def as_browse_webdlg(url) dlg = UI::WebDialog.new("Find a SketchUp plugin...", true, "Ruby Browser 2", 960, 720, 150, 150, true); dlg_html="

« BACK | RELOAD | NEXT »

Browse to a plugin and save it somewhere. If you want the plugin to automatically load with SketchUp, save it in this folder: #{Sketchup.find_support_file("plugins")}. Otherwise you'll have to load it manually.
Plugins have a RB file extension (Ruby script). Some may come in a ZIP archive that must be unzipped first.

" dlg.set_html(dlg_html) dlg.show_modal result = UI.messagebox "Do you want to load a plugin now?", MB_YESNO if (result == 6) # Yes as_load_plugin_file end end # as_browse_webdlg def as_pluginloader_help begin readmefile = "#{File.dirname(__FILE__)}\\as_pluginloader_readme.txt" helpcontent = File.readlines(readmefile) UI.messagebox helpcontent, MB_MULTILINE, "Plugin/Ruby Resources Help" rescue UI.messagebox "Couldn't find the readme file (as_pluginloader_readme.txt).\nPlease go to my website for more information:\nhttp://www.alexschreyer.net/projects/plugin-loader-for-sketchup/" end end # as_pluginloader_help # ==================================================== # filename = __FILE__ if !file_loaded?(filename) # get the SketchUp plugins menu plugins_menu = UI.menu("Plugins") as_rubymenu = plugins_menu.add_submenu("Plugin/Ruby Resources") if as_rubymenu as_rubymenu.add_item("Load single plugin...") { as_load_plugin_file } as_rubymenu.add_item("Load plugins... (entire folder)") { as_load_plugin_folder } as_rubymenu.add_separator as_rubymenu.add_item("Google - Plugins") { as_browse_webdlg("http://sketchup.google.com/download/plugins.html") } as_rubymenu.add_item("Google - Ruby Scripts") { as_browse_webdlg("http://sketchup.google.com/download/rubyscripts.html") } as_rubymenu.add_item("SketchUcation - Plugin Index") { as_browse_webdlg("http://www.sketchucation.com/?page_id=1297") } as_rubymenu.add_item("Ruby Library Depot") { as_browse_webdlg("http://www.crai.archi.fr/RubyLibraryDepot/Ruby/RUBY_Library_Depot.htm") } as_rubymenu.add_item("SCF - Visual Plugin Index") { as_browse_webdlg("http://www.sketchucation.com/forums/scf/viewtopic.php?f=180&t=16909") } as_rubymenu.add_item("pushpullbar - Visual Plugin Index") { as_browse_webdlg("http://www.pushpullbar.com/forums/ruby-scripts/9467-visual-index-ruby-scripts.html") } as_rubymenu.add_separator as_progmenu = as_rubymenu.add_submenu("Developer Reference") if as_progmenu as_progmenu.add_item("SketchUp Ruby API") { UI.openURL "http://code.google.com/apis/sketchup/docs/" } as_progmenu.add_item("SketchUcation Forums (SCF)") { UI.openURL "http://www.sketchucation.com/forums/scf/index.php" } as_progmenu.add_item("SCF - Jim's Post") { UI.openURL "http://www.sketchucation.com/forums/scf/viewtopic.php?f=180&t=10142" } as_progmenu.add_item("SketchUp Ruby Developers Group") { UI.openURL "http://groups.google.com/group/google-sketchup-developers" } as_progmenu.add_separator as_progmenu.add_item("Ruby QuickRef") { UI.openURL "http://www.zenspider.com/Languages/Ruby/QuickRef.html" } as_progmenu.add_item("Ruby Docs") { UI.openURL "http://www.ruby-doc.org/docs" } as_progmenu.add_item("rubylearning.com") { UI.openURL "http://rubylearning.com/satishtalim/tutorial.html" } end as_rubymenu.add_separator as_rubymenu.add_item("Help") { as_pluginloader_help } end # Let Ruby know we have loaded this file file_loaded(filename) end