sketchucation logo sketchucation
    • Login
    🛣️ Road Profile Builder | Generate roads, curbs and pavements easily Download

    Model.X_operation

    Scheduled Pinned Locked Moved Developers' Forum
    3 Posts 3 Posters 143 Views 3 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.
    • M Offline
      MartinRinehart
      last edited by

      Is anybody using model.X_operation methods? Any pointers for when these are helpful?

      Thanks!

      Author, Edges to Rubies - The Complete SketchUp Tutorial at http://www.MartinRinehart.com/models/tutorial.

      1 Reply Last reply Reply Quote 0
      • thomthomT Offline
        thomthom
        last edited by

        @martinrinehart said:

        Is anybody using model.X_operation methods? Any pointers for when these are helpful?

        Thanks!

        Yes.

        model.start_operation('Cool Stuff', true) #lots of ruby work model.commit_operation
        Now all the ruby work is grouped together so they are undone at at once. If you don't do this, and you draw ten lines, when you must undo ten times to get to the state before the operation.

        The first argument, the string, will be what you see in the Undo menu - "Undo Cool Stuff".
        The second argument, (and third and fourth) is introduces in SU7. When the second is true, the SU UI is disabled until the next model.commit_operation. Which significantly speeds up scripts. But in order to make it SU6 compatible you must use version checking before calling it.

        you can use model.abort_operation in case you need error handling - you can use that when you encounter an error.

        Thomas Thomassen — SketchUp Monkey & Coding addict
        List of my plugins and link to the CookieWare fund

        1 Reply Last reply Reply Quote 0
        • Chris FullmerC Offline
          Chris Fullmer
          last edited by

          Yeah, I use start_operation and abort_operation in pretty much every script. They work with the "undo stack". So if you write a script that loops 20 times and adds a line in each loop, SketchUp will count that as 20 separate operations. So to fix wthat, you can do:

          ` model.start_operation "Line Adder"

          code to add my lines....

          model.commit_operation`

          By wrapping the code within the start and commit operations, it all just turns into a single commend. So ctrl-z (or EDit > Undo) will undo all 20 lines in one shot. AND the "Line Adder" text will be displayed in the Edit > Undo menu.

          Chris

          Lately you've been tan, suspicious for the winter.
          All my Plugins I've written

          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