sketchucation logo sketchucation
    • Login
    ℹ️ GoFundMe | Our friend Gus Robatto needs some help in a challenging time Learn More

    Undo shifts geometry

    Scheduled Pinned Locked Moved Developers' Forum
    5 Posts 2 Posters 228 Views
    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.
    • thomthomT Offline
      thomthom
      last edited by

      I am currently writing a tool that generates geometry inside the currently open group. And when you open a group/component SU transforms the co-ordinates to global co-ordinates.

      In order to ensure the geometry I generate starts at local 0,0,0 I transform all the 3d points I use to generate the mesh with model.edit_transform.

      And that works fine.

      If I undo while inside the group everythings works fine.

      But, if I undo after exiting the group - the geometry then gets offset from where it should be. The offset is the same as the offset from the groups' parent origin to the group.

      How on earth can I avoid that?

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

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

        hm... the issue appear to be related to using model.close_active I see the same behaviour with native tools if I use this.

        Example:
        Open a group with a cube
        Push-Pull a face
        Type model.close_active into the Ruby Console
        Undo

        As you undo the push-pulled face is shifted.

        Also, normally when you edit a group it appears in the undo stack "Undo Close" - but when you use model.close_active there is no entry in the undo stack.

        From what I gather - using this method confuses the co-ordinates SU uses for undo/redo.

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

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

          Aaaaaaarrggh!!!!
          Is there any other way to close the current context?

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

          1 Reply Last reply Reply Quote 0
          • TIGT Offline
            TIG Moderator
            last edited by

            Rather than using 'undo'... I'd extend the tool's onCancel() and deactivate() methods so that they reset everything back as it was when you kicked off - e.g. in activate() you'd remember the objects' transformations and set them back to those as part of the 'undo', and/or keep a running array / hash of all new geometry [best kept grouped until it's finally ' committed' because erasing the group will never affect the other geometry] and erase! it all on an 'undo'...
            Wrapped in a start_/commit_operation block it will all undo/redo after the commit - the main problem is breaking the tool's work with an <Esc> or starting another tool part way through - hence my suggestions above... See how I do it in WorkPlane.rb...

            TIG

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

              No - I need to ensure that when the tool deactivated that the group is closed.

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

              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