Moving Smoothly
-
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?
-
Use the Animation class. Or a timer.
-
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
-
Maybe the view just isn't refreshing on each iteration? Try adding a view.invalidate of view.refresh before each sleep.
-
-
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
-
@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
Advertisement