sketchucation logo sketchucation
    • Login
    🤑 SketchPlus 1.3 | 44 Tools for $15 until June 20th Buy Now

    Auto Reload Plugin folder

    Scheduled Pinned Locked Moved Developers' Forum
    4 Posts 2 Posters 1.6k Views 2 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.
    • M Offline
      Morgan74
      last edited by

      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.

      1 Reply Last reply Reply Quote 0
      • M Offline
        Morgan74
        last edited by

        Here is an example of the error message :

        http://lh5.ggpht.com/_6btJdjutpH4/TKwn8qi67AI/AAAAAAAACMI/tWAdzkZTxPM/s800/Error.PNG

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

          Would help if it included the traceback message so one know exactly where the error occurred.

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

          1 Reply Last reply Reply Quote 0
          • M Offline
            Morgan74
            last edited by

            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:in AutoReload'", "C:/Program Files (x86)/Google/Google SketchUp 7/Plugins/Morgan74DevTools.rb:44:in upto'", "C:/Program Files (x86)/Google/Google SketchUp 7/Plugins/Morgan74DevTools.rb:44:in AutoReload'", "C:/Program Files (x86)/Google/Google SketchUp 7/Plugins/Morgan74DevTools.rb:35:in startTimer'", "C:/Program Files (x86)/Google/Google SketchUp 7/Plugins/Morgan74DevTools.rb:34:in call'"]

            But you have in the error message the line of the error and a "small" description :

            http://lh5.ggpht.com/_6btJdjutpH4/TKw-MbBTbgI/AAAAAAAACMQ/CiQ9UrtbW9A/s800/Error2.PNG

            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