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

    Moving Smoothly

    Scheduled Pinned Locked Moved Developers' Forum
    7 Posts 5 Posters 363 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
      MartinRinehart
      last edited by

      I want to move things smoothly. I'm experimenting with thread functions, so far without success. In the sample code, I added a sleep( 1 ) to a move/copy routine, hoping to see copies added at 1 second intervals. What I see is a long wait and then everything appears at once.

      
      def move_copy( component, distance, number_of_copies )
      
      =begin
      Creates an outer array, moving a component "distance" as many times as specified.
      
      "distance" is a vector, an array of [r, g, b].
      
      "number_of_copies" is like the "Nx" in the VCB after a Move/Copy.
      For 15 steps, you make 14 copies.
      =end
      
      	ents = Sketchup.active_model.entities
      
      	defi = component.definition # the original component's definition
      	trans = component.transformation # the original's transformation
      	pt = trans.origin # the original's location, a Point3d
      
      	for i in ( 1..number_of_copies )
      		pt += distance
                  # add vector to Point3d getting new Point3d
      		trans = Geom;;Transformation.new( pt )
                  # create new Transformation at the new Point3d
      		ents.add_instance( defi, trans )
                  # add another instance at the new Point3d
              sleep( 1 )
      	end
      
      end # of move_copy()
      
      
      

      Ideas?

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

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

        Use the Animation class. Or a timer.

        Hi

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

          Or a frame change observer to animate entities a'tween scenes.

          Some plugins that use these techniques:

          • Proper Animation - morrisdov
          • mover - cmd
          • mover modified with easings and dialog
          • SketchyPhysics
          • animation.rb - @last
          • animation2.rb - @last
          • animated clock - todd burch
          • transformer beta - didier bur

          Hi

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

            Maybe the view just isn't refreshing on each iteration? Try adding a view.invalidate of view.refresh before each sleep.

            1 Reply Last reply Reply Quote 0
            • M Offline
              MartinRinehart
              last edited by

              @jim said:

              Or a timer.

              Thanks Jim. Lininger's piece has me moving smoothly.

              @avariant said:

              Maybe the view just isn't refreshing on each iteration? Try adding a view.invalidate of view.refresh before each sleep.

              Thanks. invalidate() didn't work but refresh() worked, tho not so smoothly.

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

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

                Don't forget that refresh is new to 7.1 (or was it 7.0?). Anyhow, it is new and not compatible with older versions...

                Chris

                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

                  @chris fullmer said:

                  Don't forget that refresh is new to 7.1 (or was it 7.0?). Anyhow, it is new and not compatible with older versions...

                  Chris

                  7.1
                  http://code.google.com/intl/nb/apis/sketchup/docs/releases.html

                  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