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

Undo shifts geometry

Scheduled Pinned Locked Moved Developers' Forum
5 Posts 2 Posters 228 Views 2 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.
  • T Offline
    thomthom
    last edited by 30 Sept 2010, 20:06

    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
    • T Offline
      thomthom
      last edited by 30 Sept 2010, 20:45

      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
      • T Offline
        thomthom
        last edited by 30 Sept 2010, 20:51

        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
        • T Offline
          TIG Moderator
          last edited by 30 Sept 2010, 22:21

          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
          • T Offline
            thomthom
            last edited by 1 Oct 2010, 06:06

            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
            1 / 1
            • First post
              5/5
              Last post
            Buy SketchPlus
            Buy SUbD
            Buy WrapR
            Buy eBook
            Buy Modelur
            Buy Vertex Tools
            Buy SketchCuisine
            Buy FormFonts

            Advertisement