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

How do you make Ruby Scripts Pause

Scheduled Pinned Locked Moved Developers' Forum
6 Posts 5 Posters 1.8k 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.
  • M Offline
    mrichards
    last edited by 6 May 2010, 16:37

    Sorry if this has been discussed before..
    I am trying to simulate "animation" by using the transform! method on a group, to show the group moving. It works fine (I think) but happens too fast. I tried adding a "sleep .1" line in the Ruby code but then each transform! doesnt show up, only the last one, however, it does seem to take about the right amount of time. Is there a better way to make the code pause or wait? Or is there a way to make that "transformed" group actually visible. Any ideas or examples on how to show a group moving??

    1 Reply Last reply Reply Quote 0
    • J Offline
      Jim
      last edited by 6 May 2010, 16:46

      Hi Mark, welcome to the forum.

      I would recommend instead of simulating an animation, you make it an actual Animation .

      This example uses the SketchUp timer to create an animation - also a good technique:

      Link Preview Image
      Animate Yo' Cheese

      Posted by Scott Lininger, SketchUp Engineer Drawing foodstuffs in SketchUp is fantastically cool, but at the end of the day you wind up wit...

      favicon

      (sketchupapi.blogspot.com)

      However, to actually answer your question... you can call view.refresh to force an update of the view before you pause.

      Although I think you'll find using sleep won't work as you expect as it pauses all of SketchUp, not just the Ruby part.

      Hi

      1 Reply Last reply Reply Quote 0
      • C Offline
        cjthompson
        last edited by 6 May 2010, 17:25

        Has anyone figured out how to use threads fluidly, so that ruby and regular sketchup will work at the same time?

        1 Reply Last reply Reply Quote 0
        • M Offline
          MartinRinehart
          last edited by 6 May 2010, 17:35

          @jim said:

          Hi Mark, welcome to the forum.

          I would recommend instead of simulating an animation, you make it an actual Animation .

          Amen.

          @jim said:

          This example uses the SketchUp timer to create an animation - also a good technique:

          Link Preview Image
          Animate Yo' Cheese

          Posted by Scott Lininger, SketchUp Engineer Drawing foodstuffs in SketchUp is fantastically cool, but at the end of the day you wind up wit...

          favicon

          (sketchupapi.blogspot.com)

          I'd not be going there. If memory serves, the timer really wants an integer, so any time less than a second is no time at all.

          @jim said:

          Although I think you'll find using sleep won't work as you expect as it pauses all of SketchUp, not just the Ruby part.

          Right. I made several attempts to go down that road. Some were failures. The others were miserable failures.

          The right way to do it is to create a class that implements the Animation interface.

          I recommend Chapter 16 of my tutorial . It explains how to use the Animation interface and provides classes that you can call to move, scale and rotate things without ever needing the transformation matrix.

          When you look at the sample code in the Animation interface doc, you'll see it calls view.show_frame. You want yours to call view.show_frame( delay_time ). A time of 1.0/30.0 would run at 30 frames per second if your nextFrame() method took no time at all. That would be a good place to start if you really want about 24 fps.

          Scarpino has a chapter on animation in Automatic SketchUp, also. That's the way to go if you want to do an animated human.

          Author, Edges to Rubies - The Complete SketchUp Tutorial at http://www.MartinRinehart.com/models/tutorial.

          1 Reply Last reply Reply Quote 0
          • M Offline
            MartinRinehart
            last edited by 6 May 2010, 17:38

            @cjthompson said:

            Has anyone figured out how to use threads fluidly, so that ruby and regular sketchup will work at the same time?

            I tried. Miserable failures all.

            Author, Edges to Rubies - The Complete SketchUp Tutorial at http://www.MartinRinehart.com/models/tutorial.

            1 Reply Last reply Reply Quote 0
            • T Offline
              thomthom
              last edited by 6 May 2010, 21:28

              @cjthompson said:

              Has anyone figured out how to use threads fluidly, so that ruby and regular sketchup will work at the same time?

              All attempts to use threads I've heard about had failed. Apparently it is a no-go.

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

              1 Reply Last reply Reply Quote 0
              • 1 / 1
              1 / 1
              • First post
                1/6
                Last post
              Buy SketchPlus
              Buy SUbD
              Buy WrapR
              Buy eBook
              Buy Modelur
              Buy Vertex Tools
              Buy SketchCuisine
              Buy FormFonts

              Advertisement