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

    Timeout for Ruby Scripts

    Scheduled Pinned Locked Moved Developers' Forum
    6 Posts 4 Posters 415 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.
    • J Offline
      Jim
      last edited by

      I am experimenting with a way to pause running scripts, and this is what I have so for. I don't have all that deep of an understanding of threads, so if this is going in the wrong direction, let me know.

      Please try this out if you have time. You will likely need to adjust the count and timeout variables for your system.

      I don't know what kind of performance penalty using the thread variable imposes, but it sure is nice to have a progress report as you go; and could easily show an estimated time for completion.

      Eventually, I would like to make this transparent by providing a simple wrapper for making the call, and integrating into start_operation/commit_operation/abort_operation.

      
      
      model    = Sketchup.active_model
      entities = model.entities
      
      count    = 10000
      timeout  = 3 # seconds
      
      thr1 = Thread.new {
          z = 0
          count.times do |i|
      	Thread.current[;i] = i
      	x = i + 1
      	p1 = [0, 0, z]
      	p2 = [x, 0, z]
      	p3 = [x, x, z]
      	p4 = [0, x, z]
      	entities.add_face p1, p2, p3, p4
          end
      }
      
      while thr1.alive?
          thr1.join(timeout)
          break unless thr1.alive?
          # model.active_view.invalidate
          if( UI.messagebox("#{thr1[;i]} of #{count} complete.\n\nContinue?", MB_YESNO) == IDNO )
      	Thread.kill thr1
          end
      end
      
      
      
      

      ruby_timeout.rb

      Hi

      1 Reply Last reply Reply Quote 0
      • J Offline
        Jim
        last edited by

        I am getting the same sort of increasing slow-downs as Chris was asking about. The time between each pause increase the more geometry is added.

        Hi

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

          Grrr thats annoying. Is it messing up the ability of the timer to work right?

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

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

            Does it help taking out the garbage? Using that GC trick?

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

            1 Reply Last reply Reply Quote 0
            • tbdT Offline
              tbd
              last edited by

              I don't think so, it is more a limitation of SU openGL architecture than ruby.

              SketchUp Ruby Consultant | Podium 1.x developer
              http://plugins.ro

              1 Reply Last reply Reply Quote 0
              • J Offline
                Jim
                last edited by

                @jim said:

                I am getting the same sort of increasing slow-downs as Chris was asking about. The time between each pause increase the more geometry is added.

                Oops, not quite. I was creating and exploding groups when I wrote the above. When I just add plain geometry, the timeout appears to work alright.

                But... the pause between when my dialog is visible and when it actually becomes click-able is getting longer.

                I think I'm beating a dead horse.

                Hi

                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