sketchucation logo sketchucation
    • Login
    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!
    πŸ«› Lightbeans Update | Metallic and Roughness auto-applied in SketchUp 2025+ Download

    View.refresh behavior

    Scheduled Pinned Locked Moved Developers' Forum
    3 Posts 3 Posters 597 Views 3 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
      mptak
      last edited by

      mod = Sketchup.active_model # Open model
      ent = mod.entities # All entities in model
      sel = mod.selection # Current selection
      view = mod.active_view
      tran1a=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]
      tran1=Geom;;Transformation.new(tran1a)
      tran2a=[5200,0,0,0,0,75,0,0,0,0,1,0,0,0,0,1]
      tran2=Geom;;Transformation.new(tran2a)
      for i in 1..100 do
          tr=Geom;;Transformation.interpolate(tran1,tran2,i*0.01)
          ent[0].transformation=tr
          newview=view.refresh
          sleep 0.01
          puts i
      end
      

      This does not seem to refresh the screen with every view.refresh. Any suggestions/explanations?
      (for this application the intent is to growing a unit cube(the first entity) which I intended to iterate in 100 steps.

      1 Reply Last reply Reply Quote 0
      • A Offline
        Anton_S
        last edited by

        There are two things happening here:

        1. The view is redrawn every time you assign transformation to the object via the ent.transformation= function; Use ent.move! new_tra instead if you want to use view.refresh function as the only function for redrawing the view.
        2. Your timestep is a little too small. From my experiences on my PC, I figured min refresh delay is 1/64, which is ~0.016 seconds, while your refresh delay is 1/100 (0.01). That's why your view is not always refreshed I suppose. I got 1/64 from calculating timestep in view animation nextFrame function. I think view.refresh and nextFrame are interconnected, but I have not done tests particularly with the view refresh function, so this second point could be false.
        1 Reply Last reply Reply Quote 0
        • thomthomT Offline
          thomthom
          last edited by

          For animations it's best to use the Animation class instead of using sleep() and forcing a screen refresh.
          http://www.sketchup.com/intl/en/developer/docs/ourdoc/animation

          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
          • First post
            Last post
          Buy SketchPlus
          Buy SUbD
          Buy WrapR
          Buy eBook
          Buy Modelur
          Buy Vertex Tools
          Buy SketchCuisine
          Buy FormFonts

          Advertisement