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

    Implementing Todds' Progress Bar?

    Scheduled Pinned Locked Moved Developers' Forum
    12 Posts 4 Posters 752 Views 4 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.
    • T Offline
      tomot
      last edited by

      Kwok: thank you for your input. πŸ˜„ I could not agree with you more, Todd has been a valuable Ruby member.

      thomthom: I will change from globals after I have finished the entire script. Since many of my Rubies rely heavily on exact xyz co-ordinates. I usually start with globals, so I can evaluate them manually in the Ruby Console as a dbl. check should I have made a math mistake in a particular expression.

      [my plugins](http://thingsvirtual.blogspot.ca/)
      tomot

      1 Reply Last reply Reply Quote 0
      • T Offline
        tomot
        last edited by

        @kyyu said:

        Basically you just make a new progress bar and place a counter/update command in your loop of interest.
        -Kwok

        I was πŸŽ‰ ing to soon! The point raised about the loop of interest is very compelling. There appear to be 3 loops of interest. the Vpanes theHpanes, and the most time consuming appears to be:

        face.material= Sketchup;;Color.new( 79, rand(172), 200)
        

        its interesting that:

        face.material = Sketchup;;Color.new(255, 255, 255)
        

        takes no time at all.

        So going forward: Do I add the 3 loops in some fashion, or can I express the 3 variables into one

         pb = ProgressBar.new (etc,etc,etc) 
        

        statement ?

        [my plugins](http://thingsvirtual.blogspot.ca/)
        tomot

        1 Reply Last reply Reply Quote 0
        • T Offline
          todd burch
          last edited by

          If the 3 loops are nested, you can just use the outer loop and have one progress bar.

          If you have 3 separate loops, you can have a unique instance of a progressbar in each one.

          Thanks, Todd

          1 Reply Last reply Reply Quote 0
          • K Offline
            kyyu
            last edited by

            Hi tomot,

            The Progress Bar is an excellent plugin. Thanks Todd! I just recently added it to 2 of my plugins. Try the code below. I just added 4 lines. Basically you just make a new progress bar and place a counter/update command in your loop of interest. Oh, and I guess you need the require statement at the beginning: require 'progressbar.rb'

            -Kwok

            if( $type == "Tile Random Thickness" )
            
            z = 0
            pb = ProgressBar.new($vpanes,"Processing Panes")  
                 
                1.upto($vpanes) do |i|
                  x = ($vtile*i)+(i*$space)  
                  1.upto($hpanes) do |j|
                   y = ($htile*j)+(j*$space) 
                    
               o = $pt3.offset($hVec, y - $space).offset($vVec, x - $space)
                    pt1 = o.offset($hVec, -$htile)
               pt2 = o.offset($vVec, -$vtile)
               pt3 = pt1.offset($vVec, -$vtile)
                
               #make the geometry 
                face = entities.add_face o, pt2, pt3, pt1
                face.material= Sketchup;;Color.new( rand(255), rand(255), rand(255))
                face.reverse!
                face.pushpull ($tthick+rand(20))
                  end
            z+=1
            pb.update(z)
            
                end
            end #if 
            
            1 Reply Last reply Reply Quote 0
            • T Offline
              tomot
              last edited by

              Its really simple once I stopped making it difficult. I lost track of the fundamentals of the upto routine, which was actually multiplying a number of horiz elements by a number of vertical elements. Hence the revised code snippet makes the progress bar measure the correct variables πŸŽ‰

                z=0  
                pb= ProgressBar.new($hpanes*$vpanes,"Processing panes") 
                  
                  1.upto($vpanes) do |i|
                    x = ($vtile*i)+(i*$space) 
                     1.upto($hpanes) do |j|
              	      y = ($htile*j)+(j*$space) 
                ------------------------SNIP--------------------  
                z+=1
                pb.update(z)      
              

              [my plugins](http://thingsvirtual.blogspot.ca/)
              tomot

              1 Reply Last reply Reply Quote 0
              • K Offline
                kyyu
                last edited by

                If you do it that way, then you would have to advance the counter and update for both loops. Like Todd said, you only have to do the outer loop, because it can't finish until all nested loops do.

                -Kwok

                1 Reply Last reply Reply Quote 0
                • T Offline
                  tomot
                  last edited by

                  @kyyu said:

                  If you do it that way, then you would have to advance the counter and update for both loops. Like Todd said, you only have to do the outer loop, because it can't finish until all nested loops do.

                  -Kwok

                  Kwok, I'm only using one outer loop. The -----SNIP----- was supposed to represent the rest of the code which I did not want to repeat. I'm trying to be more like πŸ’š Also the rand function has no bearing on the amount of time it take to generate the randomly colored tiles, since its within the nested loop.

                  [my plugins](http://thingsvirtual.blogspot.ca/)
                  tomot

                  1 Reply Last reply Reply Quote 0
                  • T Offline
                    todd burch
                    last edited by

                    The code looks good to me.

                    My comment about the "outer loop" should have really have been phrased as "once somewhere in the nesting of the loops". Where it was placed is where I would have placed it - in the meat of processing.

                    If, for an extreme example, two progress bars were made, one for horizontals and another for verticals, it would work, but the status bars would be bouncing between the two, making it overly complicated and confusing to the user.

                    1 Reply Last reply Reply Quote 0
                    • K Offline
                      kyyu
                      last edited by

                      Interesting! I see what you guys are doing now and learned something. πŸ˜„ -Kwok

                      1 Reply Last reply Reply Quote 0
                      • T Offline
                        tomot
                        last edited by

                        Thanks guys, without your input, I would have been watching the Bachelor 🀒 .............I'm kidding!
                        I will post this Ruby when I get it in STILL better shape.

                        [my plugins](http://thingsvirtual.blogspot.ca/)
                        tomot

                        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