Can page/scene creation be undone in undo/redo system?
-
I've been trying to make nice with the undo system (firstly by wrapping a start/commit around the code) and I notice that when attempting to 'undo' after running my ComponentScenes plugin the pages created are not removed. (I further notice that manually created pages appear to not go away with manual undo.) The created layers and copied components all disappear politely. 'Undo' on a model where a large number of components were processed tends to kill SU completely, which is unfriendly.
I see the ModelObserver operation methods listed but can't work out how to make use of them from the doc found so far and in fact ThomThom's list of observer issues suggests maybe it wouldn't even work properly. Has anyone found a good explanation of how I might improve my undo/redo?
-
@tim said:
'Undo' on a model where a large number of components were processed tends to kill SU completely, which is unfriendly.
If Sketchup is at or higher than 7, use the 2nd argument to disable the UI. (Won't completely solve "whiteout", but helps a bit.)
# assume @@text[;undo] is the text string, or format string, # you will display in the menu, for the undo operation; begin if Sketchup.version.to_i >= 7 mdl.start_operation( @@text[;undo], true ) else mdl.start_operation( @@text[;undo] ) end # # time intensive code here # mdl.commit_operation() rescue mdl.abort_operation() puts( @@text[;error] ) end
-
there is also a thread dedicated to speed:
-
That's the usage I put in - with the second parameter 'true'. It does indeed speed up making many scenes, quite noticeably.
I haven't fully characterised how many scenes need to be undone to cause a crash (EDIT - I said originally 'kill' and I realised you might be thinking 'slow down horribly' rather than crash, burn, quit rudely etc) but since 'a few' works OK (except for the damned pages staying in place instead of going away) and 'a few dozen' crashes, I guess it's somewhere in the middle.
Advertisement