sketchucation logo sketchucation
    • Login
    πŸ€‘ SketchPlus 1.3 | 44 Tools for $15 until June 20th Buy Now

    OnTransactionStart/Commit oddities?

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

      I was trying to use the onTransactionStart and onTransactionCommit event from the ModelObserver - thinking they would trigger upon model.start_operation and model.commit_operation. But it seems they trigger for every model modification within the start/commit_operation. Though, the operations all get wrapped neatly within one undo/redo operation.

      Does anyone else see this? Or is it just me? Did it always work like this?

      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

        Test with plain SU8 installation - using Jim's observer test suite:


        (One Face with four edges in model)
        attaching #<ObserverTests::ModelObserver:0xb06051c> to #<Sketchup::Model:0xb06128c>
        Activate Move
        Initial Click
        -onTransactionStart:#<Sketchup::Model:0xb06128c>
        Move Cursor
        Second Click
        onTransactionCommit:#<Sketchup::Model:0xb06128c> -onTransactionStart:#<Sketchup::Model:0xb06128c> onTransactionCommit:#<Sketchup::Model:0xb06128c> -onTransactionStart:#<Sketchup::Model:0xb06128c> onTransactionCommit:#<Sketchup::Model:0xb06128c> -onTransactionStart:#<Sketchup::Model:0xb06128c> onTransactionCommit:#<Sketchup::Model:0xb06128c>


        Expected result would be just one onTransactionStart and onTransactionCommit.

        I really thought the ModelObserver could be used to detect the start and end of an undoable operation. But it seem to trigger as often as the EntitiesObserver.

        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

          Tested in SU 7.1.6860 : Same as SU8

          Tested in SU 6.4.265 : Works as expected! One onTransactionStart and one onTransactionCommit

          This looks to be a regression bug. 😞
          One that's turning out to be very troublesome...

          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

            However, this didn't work as expected under SU 6.4.265

            Sketchup.active_model.start_operation('test')
            -onTransactionStart:#Sketchup::Model:0x10c1f660
            onTransactionCommit:#Sketchup::Model:0x10c1f660
            true
            Sketchup.active_model.active_entities.add_cpoint [10,10,10]
            -onTransactionStart:#Sketchup::Model:0x10c1f660
            onTransactionCommit:#Sketchup::Model:0x10c1f660
            #<Sketchup::ConstructionPoint:0x10c1bdf0>
            Sketchup.active_model.active_entities.add_cpoint [20,10,10]
            -onTransactionStart:#Sketchup::Model:0x10c1f660
            onTransactionCommit:#Sketchup::Model:0x10c1f660
            #<Sketchup::ConstructionPoint:0x10c1bb20>
            Sketchup.active_model.commit_operation
            -onTransactionStart:#Sketchup::Model:0x10c1f660
            onTransactionCommit:#Sketchup::Model:0x10c1f660
            true

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

            1 Reply Last reply Reply Quote 0
            • Dan RathbunD Offline
              Dan Rathbun
              last edited by


              So this is perhaps why the poster, over at GG was having problems ??
              GoogleGroup: "transaction model question"


              Would my idea of a "manual" callback be a valid workaround ?? (If not as I've shown, perhaps moving the call after the commit call?)

              I'm not here much anymore.

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

                I was trying to use the observer because I wanted to catch any actions performed while my tool is active. It draws a UI based on the model geometry so I need to refresh when the geometry changes. And I wanted to catch events where a custom action from outside my plugin was triggered.

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

                1 Reply Last reply Reply Quote 0
                • Dan RathbunD Offline
                  Dan Rathbun
                  last edited by

                  Does the disable_ui flag have any difference in the effect ??
                  Also.. I wonder about the transparency flags.

                  But it does seem like a bug. We would want them to trigger only once, per operation, per model.

                  I'm not here much anymore.

                  1 Reply Last reply Reply Quote 0
                  • Dan RathbunD Offline
                    Dan Rathbun
                    last edited by

                    @thomthom said:

                    ... I wanted to catch any actions performed while my tool is active. ...

                    And that stickin' ToolsObserver still will not fire for Ruby tools, right?

                    I'm not here much anymore.

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

                      @dan rathbun said:

                      Does the disable_ui flag have any difference in the effect ??

                      I tried both. Same results.

                      @dan rathbun said:

                      And that stickin' ToolsObserver still will not fire for Ruby tools, right?

                      onActiveToolChanged triggers, but not onToolStateChanged.
                      Besides, many actions are not triggered by a tool.

                      😞

                      Once more I seem stomped by observers. I swear, they'll be the bane of me.

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

                      1 Reply Last reply Reply Quote 0
                      • Dan RathbunD Offline
                        Dan Rathbun
                        last edited by

                        @thomthom said:

                        @dan rathbun said:

                        And that stickin' ToolsObserver still will not fire for Ruby tools, right?

                        onActiveToolChanged triggers, but not onToolStateChanged.

                        As I remember, onActiveToolChanged didn't give us any useful data.
                        The tool_id just says 50000 (or similar,) for ANY Ruby tool, and "RubyTool" for the tool_name.
                        I wish they would fix this...

                        @thomthom said:

                        Once more I seem stomped by observers. I swear, they'll be the bane of me.

                        I suppose the built-in Standard Ruby Observer class won't work ether huh?

                        I'm not here much anymore.

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

                          Some 'transparent' tools like Zoom or Pan don't trigger.
                          Other native-tools do trigger... BUT some have names not exactly equivalent to what you might expect.
                          Plugin tools all return the same value/name !

                          TIG

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

                            I can't find any combination of methods or observers that will let me know reliably when an operation has been committed.

                            Guess it time to brush the dust of that old State of Observers list again...

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

                            1 Reply Last reply Reply Quote 0
                            • Dan RathbunD Offline
                              Dan Rathbun
                              last edited by

                              @thomthom said:

                              I can't find any combination of methods or observers that will let me know reliably when an operation has been committed.

                              You want the Start of the OP, and the finish of the OP ??

                              I'm not here much anymore.

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

                                ...onChange half-works, ...onCommit doesn't ?

                                TIG

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

                                  @dan rathbun said:

                                  @thomthom said:

                                  I can't find any combination of methods or observers that will let me know reliably when an operation has been committed.

                                  You want the Start of the OP, and the finish of the OP ??

                                  I want to catch the commit of an operation so I know I can rebuild the geometry cache I use to draw my tool's UI.

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

                                  1 Reply Last reply Reply Quote 0
                                  • Dan RathbunD Offline
                                    Dan Rathbun
                                    last edited by

                                    OK, so are you the one writing the operation ?? or is this one of Sketchup's normal undo operations ?

                                    I'm not here much anymore.

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

                                      Bummer Thom, I just played with the oncommitaction observer yesterday for the first time and I did not encounter any oddities, but I did not test it more than just drawing a few lines.

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

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

                                        @dan rathbun said:

                                        OK, so are you the one writing the operation ?? or is this one of Sketchup's normal undo operations ?

                                        I want to catch any operation. By me, by other plugins, by SU's native commands. I'm writing a custom Select tool and therefor any operation might occur while the tool is active - and I need to know when it does.

                                        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

                                          @chris fullmer said:

                                          Bummer Thom, I just played with the oncommitaction observer yesterday for the first time and I did not encounter any oddities, but I did not test it more than just drawing a few lines.

                                          Did you draw a few lines between start/commit_operation ? and the observers triggered only once?

                                          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

                                            I didn't attach a startaction observer. I only cared about actions finishing. And in the end I decided I really wanted to watch for entities being added to the model, so I moved away quickly from the transaction observers.

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

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

                                            Advertisement