sketchucation logo sketchucation
    • Login
    🤑 SketchPlus 1.3 | 44 Tools for $15 until June 20th Buy Now

    Suspending the 'undo' stack

    Scheduled Pinned Locked Moved Developers' Forum
    8 Posts 5 Posters 1.0k Views 5 Watching
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • W Offline
      Whaat
      last edited by

      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!

      SketchUp Plugins for Professionals

      1 Reply Last reply Reply Quote 0
      • tbdT Offline
        tbd
        last edited by

        @unknownuser said:

        These methods are not what I am looking for.

        why not ? what operations are still inside the undo buffer ?

        SketchUp Ruby Consultant | Podium 1.x developer
        http://plugins.ro

        1 Reply Last reply Reply Quote 0
        • R Offline
          RickW
          last edited by

          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.

          RickW
          [www.smustard.com](http://www.smustard.com)

          1 Reply Last reply Reply Quote 0
          • W Offline
            Whaat
            last edited by

            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. 😡

            SketchUp Plugins for Professionals

            1 Reply Last reply Reply Quote 0
            • plot-parisP Offline
              plot-paris
              last edited by

              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...

              1 Reply Last reply Reply Quote 0
              • R Offline
                RickW
                last edited by

                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...

                RickW
                [www.smustard.com](http://www.smustard.com)

                1 Reply Last reply Reply Quote 0
                • fredo6F Offline
                  fredo6
                  last edited by

                  @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

                  1 Reply Last reply Reply Quote 0
                  • W Offline
                    Whaat
                    last edited by

                    thanks Fred06! I'll try that!

                    SketchUp Plugins for Professionals

                    1 Reply Last reply Reply Quote 0
                    • 1 / 1
                    • First post
                      Last post
                    Buy SketchPlus
                    Buy SUbD
                    Buy WrapR
                    Buy eBook
                    Buy Modelur
                    Buy Vertex Tools
                    Buy SketchCuisine
                    Buy FormFonts

                    Advertisement