Auto Reload Plugin folder
-
Hello,
Thanks to Jim's topic http://forums.sketchucation.com/viewtopic.php?f=180&t=31394 I wrote a plugin to reload a complete folder.
You define the folder to check and you can define some ignored files.
When the LastModificationDate change SU reload the file.
If an error occurs, a messagebox is displayed with the error message with a retry buton.My module name is Morgan74DevTools so to start the plugin just call "Morgan74DevTools.startAutoReload()" from the console, from your code or uncomment the last code line.
module Morgan74DevTools Folder = "plugins/Morgan74" IgnoredFiles = ["Morgan74ToolLoader.rb","Morgan74Tools.rb"] @timer = nil @fileList = [] @fileDate = [] def self.startAutoReload() folder = Sketchup.find_support_file(Folder) #find folder @fileList = Dir.entries(folder) #find files #remove sub-folders & Ignored files to_delete_list = IgnoredFiles @fileList.each do |f| if File.directory?(File.join(folder,f)) == true to_delete_list.push(f) end end to_delete_list.each do |f| @fileList.delete(f) end #concat folder and files @fileList.collect! {|f| File.join(folder,f)} #Save last modification Date 0.upto(@fileList.length()-1){|i| @fileDate[i] = Kernel.test(?M,@fileList[i]) } self.startTimer() end def self.startTimer() #Start Timer @timer = UI.start_timer(2, true) do self.AutoReload() end end def self.stopAutoReload() UI.stop_timer(@timer) end def self.AutoReload() 0.upto(@fileList.length()-1){|i| if Kernel.test(?M,@fileList[i]) != @fileDate[i] begin Sketchup.set_status_text("Loading ; " + @fileList[i].to_s(),SB_PROMPT) load @fileList[i] @fileDate[i] = Kernel.test(?M,@fileList[i]) rescue Exception => e #Stop timer self.stopAutoReload() msg = "AutoReload Plugin\n\n" msg << "Error loading file ;\n" + @fileList[i].to_s() + "\n\n" msg << "Error message ;\n" + e.message + "\n\n" msg << "Fix the error before click RETRY or CANCEL to stop the plugin" result = UI.messagebox(msg,MB_RETRYCANCEL) self.startTimer() if (result == 4)#Retry = restart timer end end } end end #Morgan74DevTools.startAutoReload()Next step can be reload all the folders inside the plugin folder.
-
Here is an example of the error message :
-
Would help if it included the traceback message so one know exactly where the error occurred.
-
The traceback is always the same with this plugin because the lastest method used is "load" :
["C:/Program Files (x86)/Google/Google SketchUp 7/Plugins/Morgan74DevTools.rb:48:inload'", "C:/Program Files (x86)/Google/Google SketchUp 7/Plugins/Morgan74DevTools.rb:48:inAutoReload'", "C:/Program Files (x86)/Google/Google SketchUp 7/Plugins/Morgan74DevTools.rb:44:inupto'", "C:/Program Files (x86)/Google/Google SketchUp 7/Plugins/Morgan74DevTools.rb:44:inAutoReload'", "C:/Program Files (x86)/Google/Google SketchUp 7/Plugins/Morgan74DevTools.rb:35:instartTimer'", "C:/Program Files (x86)/Google/Google SketchUp 7/Plugins/Morgan74DevTools.rb:34:incall'"]But you have in the error message the line of the error and a "small" description :
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better đź’—
Register LoginAdvertisement