sketchucation logo sketchucation
    • Login
    ℹ️ Licensed Extensions | FredoBatch, ElevationProfile, FredoSketch, LayOps, MatSim and Pic2Shape will require license from Sept 1st More Info

    Refresh plugins without restart Sketchup is possible??

    Scheduled Pinned Locked Moved Developers' Forum
    13 Posts 5 Posters 1.6k Views 5 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.
    • D Offline
      davidsuke
      last edited by

      I mean, every time I modify my plugins I must restart sketchup to watch the changes. You know som plugins or method for refresh my plugin without restart sketchup???

      Thanks guys!!

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

        if you go to the ruby console and type load "pluginname.rb" your plugin will be refreshed.

        http://remusrendering.wordpress.com/

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

          Yes, thats normal. It will sort itself out when you restart sketchup.

          there might be some clever way of avoiding it loading the extra menu items although i dont know how to do it, any clues anyone?

          http://remusrendering.wordpress.com/

          1 Reply Last reply Reply Quote 0
          • D Offline
            davidsuke
            last edited by

            @remus said:

            if you go to the ruby console and type load "pluginname.rb" your plugin will be refreshed.

            Hey man, thanks!!! It works!! But i have a little problem now, everytime I do this, in the menu of plugin appears a new plugin. If I do 3 times load "house.rb" then I have 3 House in the menu plugins, that's normal??

            In my ruby I have the next line, maybe it's wrong.

            
            UI.menu("PlugIns").add_item("house") {main}
            
            1 Reply Last reply Reply Quote 0
            • Chris FullmerC Offline
              Chris Fullmer
              last edited by

              Take a look at how box.rb in the plugins\examples folder loads itself into the menu. It starts on line 100.

              Also important to note is that it calls a method file_loaded at the very end of the script. That method is in the sketchup.rb file, so must put in a require 'sketchup.rb' at the top of your script so it can correctly call that method. You can look at the sketchup.rb file to see what goes on when that method is called.

              But the idea is that you check to see if your file is already loaded. If it is loaded, then it does not add itself to the menu system again. But if it is not loaded, then it will add itself to the menu.

              Chris

              Lately you've been tan, suspicious for the winter.
              All my Plugins I've written

              1 Reply Last reply Reply Quote 0
              • Chris FullmerC Offline
                Chris Fullmer
                last edited by

                Also, instead of manually typing in the file name in file_loaded("box.rb"), you can use file_loaded(__FILE__). FILE is a (please Jim or someone correct me if I get the object name wrong) is a constant that holds the name of the current ruby file.

                That is nice because it is easier to copy and paste between scripts, and you don't have to change anything if you rename your script after a few versions.

                Chris

                Lately you've been tan, suspicious for the winter.
                All my Plugins I've written

                1 Reply Last reply Reply Quote 0
                • D Offline
                  davidsuke
                  last edited by

                  Thanks!! I got it! like box.rb 😉

                  
                  if( not file_loaded?("House.rb") )
                  UI.menu("PlugIns").add_item("Make house") {main}
                  end
                  file_loaded("House.rb")
                  
                  

                  and I tried with FILE and works too!

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

                    Also, you can use "unless" instead of "if not", and a bit of restructuring gives you

                    unless file_loaded?(__FILE__)
                       file_loaded(__FILE__)
                       #do your stuff here
                    end
                    

                    Though it's not a big deal, it eliminates any unnecessary calls to file_loaded()

                    RickW
                    [www.smustard.com](http://www.smustard.com)

                    1 Reply Last reply Reply Quote 0
                    • D Offline
                      davidsuke
                      last edited by

                      Thanks man!!

                      And it's possible creat a plugin which reloads all the plugins in the directory plugins or the plugins you write in this plugin??

                      I mean a plugin which per example do this. "load "House.rb", like this we can reload all the plugins without write load"xxx.rb" in the ruby console.

                      1 Reply Last reply Reply Quote 0
                      • Chris FullmerC Offline
                        Chris Fullmer
                        last edited by

                        Yes, you could create a toolbar that reloads your script you are developing. That way, just click the icon you made and it will run the load myruby.rb command.

                        Have you looked into Jims webconsole? I find it to be a very handy tool. I write most of my code in it. It lets you actually write code within sketchup and just pres execute and it will run. No need to make a menu system for it at first. I generally wait until its all running smoothly then copy it over to notepad++ to add my menus and copyright info, etc.

                        Chris

                        Lately you've been tan, suspicious for the winter.
                        All my Plugins I've written

                        1 Reply Last reply Reply Quote 0
                        • D Offline
                          davidsuke
                          last edited by

                          It is a excellent tool!! Only one bad thing, no syntax highlighting, but it's great!!

                          Thanks for the advice!!

                          1 Reply Last reply Reply Quote 0
                          • P Offline
                            pecan
                            last edited by

                            @davidsuke said:

                            It is a excellent tool!! Only one bad thing, no syntax highlighting, but it's great!!

                            Thanks for the advice!!

                            If you want syntax highlighting you can use the editor here.

                            http://www.sketchucation.com/forums/scf/viewtopic.php?f=180&t=18130#p146440
                            [plugin] SuRDebug

                            1 Reply Last reply Reply Quote 0
                            • D Offline
                              davidsuke
                              last edited by

                              @pecan said:

                              @davidsuke said:

                              It is a excellent tool!! Only one bad thing, no syntax highlighting, but it's great!!

                              Thanks for the advice!!

                              If you want syntax highlighting you can use the editor here.

                              http://www.sketchucation.com/forums/scf/viewtopic.php?f=180&t=18130#p146440
                              [plugin] SuRDebug

                              That's good, and it have auto-indent too??

                              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