Revert back to saved version
-
Sketchup.undo
-
Encapsulate your 'animation' code thus:
Sketchup.active_model.start_operation("MyLovelyAnimation")
do your transformation stuff, using
Sketchup.active_model.refresh
etc as needed...afterwards, to reset everything back to where you started, use...
Sketchup.active_model.abort_operation
everything is then undone in one go.
-
... but does he have to use
transform!
instead ofmove!
inside the operation block ? -
If he's does pure 'animation' using
move!
instead oftransform!
, it will indeed not add things to the 'stack'.
But if he is also changing layer visibility etc, then that is ?
Aborting the operation will reset back to how it was before the start...
Although if he's animating the camera, he is advised to save the active view's camera immediately before starting the operation, and after aborting it to reset the view camera back to that ? -
Seems like maybe a lot of the posts have dodged the original question: when you revert a file, you close the current version and reload the saved one from disk. Can't this be done via:
# true says ignore changes and suppress the save dialog Sketchup.active_model.close true Sketchup.open_file(path_to_file)
-
.
Yes but this will work only on SketchUp 2015+close(true) = ignore changes and suppress the save dialog
filepath = Sketchup.active_model.path if Sketchup.active_model.respond_to?(;close) Sketchup.active_model.close(true) elsif RUBY_PLATFORM !~ /darwin/i # NOT OSX Sketchup.file_new end Sketchup.open_file(filepath)
-
.
TIG's Encapsulate your 'animation' code is really a better idea.But try it like this (he omitted the need for a commit_operation call.)
begin ### do everything in one go; ### # Sketchup.active_model.start_operation("MyLovelyAnimation") # ### Do your transformation stuff, using ### Sketchup.active_model.refresh etc as needed... # Sketchup.active_model.commit_operation # ### rescue => e # Just output any exception info to console; puts "Error; "<<e.inspect puts e.backtrace # optional else # Things to do only when NO errors occur; UI.messagebox("The show is over. Reset now?") ensure # Whether or not any errors occur; ### reset everything back to start Sketchup.active_model.abort_operation end
I am not sure if the messagebox will actually cause a pause before reset.
-
Going back several steps .move! works like .transform! without affecting the stack within an animation ?
Advertisement