Suspending the 'undo' stack
-
I am wondering if it is possible to disable the 'undo' feature of SketchUp. For example, in the context of a customized Ruby tool, I am performing a bunch of hiding and un-hiding of geometry while the user moves the mouse. Once the user leaves the tool, I don't want all of the hiding and un-hiding to be in the undo stack.
I know about model.start_operation and model.commit_operation. These methods are not what I am looking for.
Thanks!
-
@unknownuser said:
These methods are not what I am looking for.
why not ? what operations are still inside the undo buffer ?
-
So, basically, you could be calling hundreds of changes to edges (hidden/not hidden), flooding the undo stack (limited to 100 operations) and basically eliminating the undo capability. I can see why that would be undesirable
IIUC, you want the changes to not be part of the undo stack at all, but the one option I know about is to trap all the changes in model.set_operation/commit_operation so they appear as a single undo item. The only thing relating to geometry manipulation that is "transparent" from ruby (that I know of) is the group.move! method.
-
Thanks guys,
Maybe this snippet will explain what I am trying to do.
def onMouseMove(flags, x, y, view) if @hide ph=view.pick_helper ph.do_pick(x,y) e=ph.best_picked if e.class==Sketchup;;Group if (test_condition) e.hidden=true @hidden.push(e) end end end end
I don't want the hiding to be 'undoable'. When the user clicks the mousebutton, some geometry gets created. This is the operation that I DO want 'undoable' (which works fine). However, all of the hiding that is done in the 'onmousemove' method is also added to the undo stack.
-
Whaat, I completely understand, why you need this.
when I recently installed a v-ray trial version, exactly this happened to my SketchUp.
when I for example copied a complex object within the stage and hit Ctrl + Z, it undid the copying prozess for every single element seperately, until it ran out of memory cash...
I had to uninstall v-ray again to get rid of this unpleasant effect...
-
Unfortunately, that will have to be a v8 feature request. I can make that request (and I think it's a worthwhile one), but it won't be available for some time. For now, the best that can happen is collecting everything inside model.start_operation/commit_operation.
Sorry...
-
@whaat said:
Thanks guys,
Maybe this snippet will explain what I am trying to do.
def onMouseMove(flags, x, y, view) > > if @hide > > ph=view.pick_helper > ph.do_pick(x,y) > e=ph.best_picked > if e.class==Sketchup;;Group > if (test_condition) > e.hidden=true > @hidden.push(e) > end > end > end > end
I don't want the hiding to be 'undoable'. When the user clicks the mousebutton, some geometry gets created. This is the operation that I DO want 'undoable' (which works fine). However, all of the hiding that is done in the 'onmousemove' method is also added to the undo stack.
I had the same issue with Joint Push Pull, as I do hide faces when dragging.
The workaround I found is to do a Sketchup.start_operationbefore all, and then do an Sketchup.abort_operationwhen the edition is finished (you have also to trap it in the OnCancel method). This way, you get nothing in the Undo stack and anyway, all individual operations are in the same batch of modifs.Fredo
-
thanks Fred06! I'll try that!
Advertisement