A question about undo stack - external operation within my own start-commit


i have read some topics about the following problem already, but found no answer,


when i start an operation and create some geometry during this process (like a line following the mouse),
i am still within this operation, unless i click for the second time and commit via
this work well.

but now i found out, that

after click 1 , which calls my own model. start_operation,
the user can for example

select another layer or create a layer and so on in skecthup menues (while he is inside my operation).

those actions themselves write into the undo-stack, as far as i can see
and my commit does not work anymore.

please, can you give me any advice, how to solve this? is there a way to “remove entries” from the undo stack whithout undoing the “external” actions?

setting up observers does not help, since then the actions are already done.

thanx in advance for any help!


ps: in this topic


greg wrote:


As mentioned, you can combine all your operations. Also, you can create a counter for the number of operations added to the stack, then do

1.upto(cntr_ops) { Sketchup.undo }

to remove them.


but i cannot apply this for now…(do not understand, how to implement the code)


I would recommend to start the operation, draw and commit directly after each other, without any paus in between.


hi & thanx,
the problem is, that this would litter the undo-stack, since the help-line is created more times with the mouse movement (preview), unless the endpoint is created.
at the moment the whole thing is 1 operation (p2p).


If possible, avoid making any chances to the model until the user has finished making the input. For preview you can use the View#draw methods to only display a line, without physically adding it to the model.


oh, thanx a lot, i did not know yet about this way of displaying lines ( i suppose, this type is not added to the undo stack !),
i’ll report, if i manage it.
thank you very much for the tip!


Do NOT start the operation until after the 2nd click.
As Julia said, use rubber-banding lines drawn on the view from the 1st point to the cursor.

See the SketchUp Team’s "linetool.rb" example in the Ruby Examples extension …



This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.