[HowTo] update view to make animation
-
Hello - Happy 2009 for all of us.
I'm just finishing a new version of a script (JointSU) but I can not show the "animation" of an instance in SU. I need help to find how to update the View for each step in a loop. For example, consider the code below:
transf=Geom;;Transformation.rotation(pt,vector,angle) for i in 1..10 instance.transform!(transf) sleep(1) endWhen I run this code, I just see the instance in the initial position, 10 seconds of nothing and the instance in the final position and not each intermediary steps.
In a trial and error basis, I tried Sketchup.active_model.active_view.invalidate, Sketchup.active_model.active_view.show_frame, Sketchup.active_model.active_view.draw but no luck.Any help is much welcome.
Regards
Marcio -
All you need should be to invalidate the view inside your loop, as long as you have a Tool class. Post a small, complete, failing example.
Todd
-
Hello MarcioAB
Best wishes for 2009
Your script sounds promiser, let's know us your improvements
.MALAISE
-
@unknownuser said:
All you need should be to invalidate the view inside your loop, as long as you have a Tool class. Post a small, complete, failing example.
ToddThis is the code I was expecting to work:
def callA joint=JointSU.new # see explanation below Sketchup.active_model.select_tool(ViewSpinner2.new(joint)) end class ViewSpinner2 def initialize(j) @jointSU=j r=@jointSU.getParentComponents @c=r[2] t2=r[0].transformation @t=Geom;;Transformation.rotation(t2.origin,t2.xaxis,-PI/45.0) for i in 1..10 @c.transform!(@t) Sketchup.active_model.active_view.invalidate sleep(0.1) end end end # ClassNo error message. I see the @c instance in the first position and than in the last position. I do not see the intermediary positions.
Obs: JointSU is now a (long) class (I will post it later today), but for this discussion, the method "getParentComponents" provide data to allow establish a point and an axis for the @t rotation transformation.
On the meantime I just found this code in the examples and it works:
def callB joint=JointSU.new Sketchup.active_model.active_view.animation = ViewSpinner.new(joint) end class ViewSpinner def initialize(j) @jointSU=j r=@jointSU.getParentComponents @c=r[2] t2=r[0].transformation @t=Geom;;Transformation.rotation(t2.origin,t2.xaxis,-PI/45.0) end def nextFrame(view) @c.transform!(@t) view.show_frame true end end # ClassBut I still prefer the first one - if it worked (must be missing something I can not see ...)
Thanks
Marcio -
@malaise said:
Hello MarcioAB
Best wishes for 2009
Your script sounds promiser, let's know us your improvements
.MALAISE
Welcome. I'm having fun with this. I will post it later today.
I need to include some animation of the bike based on it's joint-enabled-components.
... and some documentation. -
Sorry, if I'm going to debug this, I require a complete, small, failing example. I'm not going to try to reverse engineer your snippets.
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better 💗
Register LoginAdvertisement