sketchucation logo sketchucation
    • 登入
    Oops, your profile's looking a bit empty! To help us tailor your experience, please fill in key details like your SketchUp version, skill level, operating system, and more. Update and save your info on your profile page today!
    ⚠️ Important | Libfredo 15.6b introduces important bugfixes for Fredo's Extensions Update

    Plugin to create a progress bar

    已排程 已置頂 已鎖定 已移動 Plugins
    23 貼文 12 Posters 4.7k 瀏覽 12 Watching
    正在載入更多貼文
    • 從舊到新
    • 從新到舊
    • 最多點贊
    回覆
    • 在新貼文中回覆
    登入後回覆
    此主題已被刪除。只有擁有主題管理權限的使用者可以查看。
    • S 離線
      Squall290586
      最後由 Squall290586 編輯

      Hi,

      I apologize for my English 😄.
      I am french and my English is not very good.
      Actually, i develop a plugin to make GCode for milling machine.

      It's not ready for the moment but despite searches I did not find progress bar for sketchup.
      Suddenly I develop this and i think that be util for another 😄.

      You can find this plugin on this link:
      https://docs.google.com/folder/d/0B9Gb-sUls44ANW1JRkM5U2lveEU/edit

      With this plugin a new class andis available.
      This class is "Squall::ProgressBar", she have 4 instance methods:

      • initialize(max, title = "In progress", waitingMessages = [])
        "max" is the maximum value of the progress bar
        "title" is the title of the popup
        "timeLeft" is the text display after the estimate seconds
        "waitingMessages" is a array with an messages array, messages are displayed during the process

      • process() {statement}
        This method display the progress bar and execute the statement

      • progress(i = 1)
        This method update the advancement of the progress bar

      • onCancel() {statement}
        This method launch the statement if the progress bar is closed

      This class have a static variable.
      This variable is initialized to true if a progress bar is active.
      The name of this is "Squall::ProgressBar.processing"

      If several progress bar are open in same time.
      They will be executed one by one.

      And for finish, this is a little example:

      
      	pb = Squall;;ProgressBar.new(200); 
      	pb.onCancel() {puts "cancel"}; 
      	pb.process() {
      		i = 0;
      		loop{
      			pb.progress();
      			i += 1;
      	 		break if(i == 200);
      	 		sleep(0.5)
      		};
      	};
      
      

      If you have any problem with that, can you send me a message with the problem?

      Thank in advance.

      A little link on a video:

      1 條回覆 最後回覆 回覆 引用 0
      • Dave RD 離線
        Dave R
        最後由 編輯

        I don't know but it sounds like you've reinvented the wheel. Congratulations!

        Etaoin Shrdlu

        %

        (THERE'S NO PLACE LIKE)

        G28 X0.0 Y0.0 Z0.0

        M30

        %

        1 條回覆 最後回覆 回覆 引用 0
        • D 離線
          driven
          最後由 編輯

          Hi

          There are at least 2 other ProgressBar.rb's around and if both are installed they mess up loads of other scripts.

          one's at smartmustard and the other came with 'VirtualWind' ruby package...

          might be wise to triple check for name and method clashes before people download it???

          even wdProgressBar would be better as it.s in a webdialog... I assume, as I haven't downloaded all the files, I'm not sure which I need.

          welcome and goodluck with the gcode...

          john

          learn from the mistakes of others, you may not live long enough to make them all yourself...

          1 條回覆 最後回覆 回覆 引用 0
          • jeff hammondJ 離線
            jeff hammond
            最後由 編輯

            @driven said:

            john

            do you think it would possible to use osx's progress bar in sketchup? i see it everywhere else..

            (borderline off topic, i know.. just something i've wandered about in the past)

            dotdotdot

            1 條回覆 最後回覆 回覆 引用 0
            • D 離線
              driven
              最後由 編輯

              @unknownuser said:

              do you think it would possible to use osx's progress bar in sketchup? i see it everywhere else..

              happy new year Jeff,
              visually, you could use it with this, drop the system image path into the html, functionally, Sketchup dosen't even know how long it will take, so theres lots of extra checking back and forth to modify the prediction, a webDialog will add less overhead then a system audit would.

              Basicly, while they keep you entertained, progress bars 'in general', if asked "How Long Will This Take" should reply "longer, now that I'm involved"

              john

              learn from the mistakes of others, you may not live long enough to make them all yourself...

              1 條回覆 最後回覆 回覆 引用 0
              • jeff hammondJ 離線
                jeff hammond
                最後由 編輯

                hny to you too!

                dunno, i'd rather stare at a cute little animation for 32 seconds than stare at a drawing for 30 seconds wondering if anything is happening. 😉

                or if someone was nerdy enough, they could probably come up with an algorithm which grabs your cpu stats then checks how many calculations the ruby is about to make then somewhat estimate the time it's going to take.

                that should be able to happen fairly quickly?

                [eDit]. well, wait... that's probably what a normal progress bar is doing anyway... 😳 😒

                dotdotdot

                1 條回覆 最後回覆 回覆 引用 0
                • S 離線
                  Squall290586
                  最後由 編輯

                  @dave r said:

                  I don't know but it sounds like you've reinvented the wheel. Congratulations!

                  Hi,

                  I test this class,
                  It's not a real progress bar it's just a update of sketchup status.
                  It open not a modal dialog

                  1 條回覆 最後回覆 回覆 引用 0
                  • S 離線
                    Squall290586
                    最後由 編輯

                    @driven said:

                    Hi

                    There are at least 2 other ProgressBar.rb's around and if both are installed they mess up loads of other scripts.

                    one's at smartmustard and the other came with 'VirtualWind' ruby package...

                    might be wise to triple check for name and method clashes before people download it???

                    even wdProgressBar would be better as it.s in a webdialog... I assume, as I haven't downloaded all the files, I'm not sure which I need.

                    welcome and goodluck with the gcode...

                    john

                    Hi,

                    despite several search, i don't found the progress bar of virtual wind.
                    Now my progress bar is finish and functional 😄

                    1 條回覆 最後回覆 回覆 引用 0
                    • J 離線
                      Jim
                      最後由 編輯

                      Hello Voignier. Welcome to the forum and thank you for contributing to our community.

                      Every SketchUp plugin must share the same work space, which means plugins must not change the environment for other plugins. This means not using global variables, enclosing your code in a namespace, and not changing SketchUp's classes or modules.

                      Doing any of these will get the plugin banned from this forum. Thanks.

                      
                      require 'sketchup.rb'
                      
                      module Sketchup
                        def Sketchup.application_dir()
                          Dir.chdir(Sketchup.template_dir)
                          Dir.chdir("../../..")
                          return Dir.getwd
                        end
                      end
                      
                      

                      Hi

                      1 條回覆 最後回覆 回覆 引用 0
                      • S 離線
                        Squall290586
                        最後由 編輯

                        @jim said:

                        Hello Voignier. Welcome to the forum and thank you for contributing to our community.

                        Every SketchUp plugin must share the same work space, which means plugins must not change the environment for other plugins. This means not using global variables, enclosing your code in a namespace, and not changing SketchUp's classes or modules.

                        Doing any of these will get the plugin banned from this forum. Thanks.

                        
                        > require 'sketchup.rb'
                        > 
                        > module Sketchup
                        >   def Sketchup.application_dir()
                        >     Dir.chdir(Sketchup.template_dir)
                        >     Dir.chdir("../../..")
                        >     return Dir.getwd
                        >   end
                        > end
                        > 
                        

                        Hi,

                        I change the module sketchup with a new method it's not an existant method.
                        It's very important?

                        If yes, i will changed my plugin immediatelly.

                        1 條回覆 最後回覆 回覆 引用 0
                        • S 離線
                          Squall290586
                          最後由 編輯

                          I change the plugin, i create a new module with a new method.
                          The link is be updated (version 1.02)

                          1 條回覆 最後回覆 回覆 引用 0
                          • A 離線
                            Aerilius
                            最後由 編輯

                            Hi,
                            we usually use an author module and then a module name of our choice ( Utils is a very generic word). Like

                            module Squall
                              module Utils
                              end
                            end
                            
                            1 條回覆 最後回覆 回覆 引用 0
                            • S 離線
                              Squall290586
                              最後由 編輯

                              @aerilius said:

                              Hi,
                              we usually use an author module and then a module name of our choice ( Utils is a very generic word). Like

                              module Squall
                              >   module Utils
                              >   end
                              > end
                              

                              Indeed, i change all my class and i prefixe all that by the module Squall.

                              1 條回覆 最後回覆 回覆 引用 0
                              • Chris FullmerC 離線
                                Chris Fullmer
                                最後由 編輯

                                One reason to not add methods to existing SketchUp space is because in the future, SketchUp itself might decide to add that same method. Then you'll be conflicting.

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

                                1 條回覆 最後回覆 回覆 引用 0
                                • thomthomT 離線
                                  thomthom
                                  最後由 編輯

                                  @squall290586 said:

                                  I change the module sketchup with a new method it's not an existant method.
                                  It's very important?

                                  I recommend you read this: http://www.thomthom.net/thoughts/2012/01/golden-rules-of-sketchup-plugin-development/

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

                                  1 條回覆 最後回覆 回覆 引用 0
                                  • S 離線
                                    Squall290586
                                    最後由 編輯

                                    @thomthom said:

                                    @squall290586 said:

                                    I change the module sketchup with a new method it's not an existant method.
                                    It's very important?

                                    I recommend you read this: http://www.thomthom.net/thoughts/2012/01/golden-rules-of-sketchup-plugin-development/

                                    Thanks for this link, I will to read that carefully 😄.

                                    1 條回覆 最後回覆 回覆 引用 0
                                    • S 離線
                                      Squall290586
                                      最後由 編輯

                                      Hi,

                                      A new version of my progress bar is available (Version 1.1).
                                      After severals tests, I modify the generation of the web page using jQuery JS framework.

                                      And now, a processing management is available to execute the processes one by one.

                                      1 條回覆 最後回覆 回覆 引用 0
                                      • L 離線
                                        LFloissac
                                        最後由 編輯

                                        Hi Gregory,

                                        "Félicitations" (I'm French too) for your plugin.

                                        I'm using SU Pro - 8.0.14346 and your plugin ProgressBar v1.29
                                        I've tried to use your plugin and obtain the following message: "Run aborted. Error: progress_bar.rb:48:in `set_file': can't convert nil into String"
                                        the code used to call the plugin is from your example (see above). Do you have a suggestion ?

                                        require 'progress_bar.rb'

                                        pb = Squall::ProgressBar.new(200);
                                        pb.onCancel() {puts "cancel"};
                                        pb.process() {
                                        i = 0;
                                        loop{
                                        pb.progress();
                                        i += 1;
                                        break if(i == 200);
                                        sleep(0.5)
                                        };
                                        };

                                        1 條回覆 最後回覆 回覆 引用 0
                                        • G 離線
                                          glro
                                          最後由 編輯

                                          @lfloissac said:

                                          Hi Gregory,

                                          "Félicitations" (I'm French too) for your plugin.

                                          I'm using SU Pro - 8.0.14346 and your plugin ProgressBar v1.29
                                          I've tried to use your plugin and obtain the following message: "Run aborted. Error: progress_bar.rb:48:in `set_file': can't convert nil into String"
                                          the code used to call the plugin is from your example (see above). Do you have a suggestion ?

                                          require 'progress_bar.rb'

                                          pb = Squall::ProgressBar.new(200);
                                          pb.onCancel() {puts "cancel"};
                                          pb.process() {
                                          i = 0;
                                          loop{
                                          pb.progress();
                                          i += 1;
                                          break if(i == 200);
                                          sleep(0.5)
                                          };
                                          };

                                          line 48 of progress_bar.rb is
                                          "@dialog.set_file(Sketchup.find_support_file("progressBar.html", "/Plugins/ProgressBar/html"))"

                                          maybe it is related to the "progressBar.html" file

                                          I downloaded version 1.29 too, and the code works perfectly on my computer: a progress bar does appear on my screen

                                          1 條回覆 最後回覆 回覆 引用 0
                                          • G 離線
                                            glro
                                            最後由 編輯

                                            [quote="Squall290586"]

                                            And for finish, this is a little example:

                                            
                                            	pb = Squall;;ProgressBar.new(200); 
                                            	pb.onCancel() {puts "cancel"}; 
                                            	pb.process() {
                                            		i = 0;
                                            		loop{
                                            			pb.progress();
                                            			i += 1;
                                            	 		break if(i == 200);
                                            	 		sleep(0.5)
                                            		};
                                            	};
                                            
                                            

                                            i just downloaded v 1.29, installed it, and typed the code above in a ruby editor; it works fine

                                            I am not sure about how to use this plugin in a plugin of mine, though...

                                            I guess that i have to type this code in mine, and adjust the increase of "i" parameter according to my process; it is correct?

                                            or could you give a few words of explanation?

                                            thank you

                                            1 條回覆 最後回覆 回覆 引用 0
                                            • 1
                                            • 2
                                            • 1 / 2
                                            • 第一個貼文
                                              最後的貼文
                                            Buy SketchPlus
                                            Buy SUbD
                                            Buy WrapR
                                            Buy eBook
                                            Buy Modelur
                                            Buy Vertex Tools
                                            Buy SketchCuisine
                                            Buy FormFonts

                                            Advertisement