View.refresh behavior
-
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. -
There are two things happening here:
- The view is redrawn every time you assign transformation to the object via the
ent.transformation=
function; Useent.move! new_tra
instead if you want to useview.refresh
function as the only function for redrawing the view. - 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.
- The view is redrawn every time you assign transformation to the object via the
-
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
Advertisement