How to wait until scene change is completed

I’m trying to create a plugin to navigate to saved scene and do extra things

But I’m having trouble to achieve it because the code that needs to be done after scene animation(or transition) is complete is executed in the middle of transition.

I’m setting scene like below

pages.selected_page = pages[i]

but while view is moving to the scene, #TODO is executed.
I would like it to wait until it’s finished moving.

I’ve tried MyFrameChangeObserver but I couldn’t run a function inside it, it just says undefined method.

Thanks in advance

You can disable the transition. (You need to store it to restore after you done with the TODO).


model = Sketchup.active_model
pages = model.pages

#Store and disable the transition
showtransition = model.options["PageOptions"]["ShowTransition"]
model.options["PageOptions"]["ShowTransition"] = false

i = 0
pages.selected_page = pages[i]

#Restore the transition:
model.options["PageOptions"]["ShowTransition"] = showtransition 

You can achieve similar if you set Transition Time and perhaps delay to zero:

transitiontime = model.options["PageOptions"]["TransitionTime"]
slideTime = model.options["SlideshowOptions"]["SlideTime"]
model.options["PageOptions"]["TransitionTime"] = 0
model.options["SlideshowOptions"]["SlideTime"] = 0

model.options["PageOptions"]["TransitionTime"] = transitiontime 
model.options["SlideshowOptions"]["SlideTime"] = slideTime 
1 Like

This worked!

Would it work for any heavy sketchup models?

I see no reason why it shouldn’t work.

A FrameChangeObserver should work. Can you share a sample snippet that demonstrate that issue? (Sounds like that’s the real issue here)