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

    Catch when Paste In Place is performed

    Scheduled Pinned Locked Moved Developers' Forum
    10 Posts 4 Posters 334 Views 4 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 need to catch this command when it occurs so I can detect if an instance of a specific definition is added. With normal paste the PasteTool is triggered. But it doesn't when Paste In Place is invoked.

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

      1 Reply Last reply Reply Quote 0
      • AdamBA Offline
        AdamB
        last edited by

        Any reason you don't just look for all instances being added and do something its "your" definition?

        Developer of LightUp Click for website

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

          Don't see any event Observer that tells me when new instances are added globally. However, the DefinitionObserver would have been ideal for my use and I'm only interested in certain definition instances. But since it's borked I have to find other ways to find out when that happens.
          By using the ToolObserver I can detect when a regular Paste is done and when a Move+Copy and RotateCopy is performed. But I find nothing to catch the Paste in Place.

          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

            EntitiesObserver

            onElementAdded

            ?

            TIG

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

              @tig said:

              EntitiesObserver

              onElementAdded

              ?

              Then I'd have to monitor every group and component definition and the model object. I'm not that familiar with the overhead of Observers. But this sounds like it'd be quite a lot of observers running...
              Anyone knows what the performance impact of doing this would be?

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

              1 Reply Last reply Reply Quote 0
              • AdamBA Offline
                AdamB
                last edited by

                Or you could monitor just the object being edited driven off onOpen, onClose ie dynamically add an observer then remove it on close.

                Adam

                But fundamentally, the semantics of some of the observer patterns is a bit pants. But the Boulder guys are well aware of this and I'm sure they'll get around to freshening it up.

                Developer of LightUp Click for website

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

                  @adamb said:

                  Or you could monitor just the object being edited driven off onOpen, onClose ie dynamically add an observer then remove it on close.

                  Adam

                  Well,.. in my experience, onClose doesn't trigger. Only onOpen... Which is another thing I work around. Though, I'm currently using Model.onActivePathChanged for that.

                  This might be something. With that, I might not need that many observers of various kinds. If I monitor the active entities for changes I might be able to simplify my script. Will give it a whack.

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

                  1 Reply Last reply Reply Quote 0
                  • AdamBA Offline
                    AdamB
                    last edited by

                    Or why not make it very simple and have a thread that wakes every few seconds to check whether XXX.instances.count has changed.

                    Probably computationally cheaper than having N instances of Observer.

                    Adam

                    Developer of LightUp Click for website

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

                      I have been thinking of timers. But I like the idea of them less than observers.
                      Will have to see what I end up with.

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

                      1 Reply Last reply Reply Quote 0
                      • J Offline
                        Jim
                        last edited by

                        @thomthom said:

                        @tig said:

                        EntitiesObserver

                        onElementAdded

                        ?

                        Then I'd have to monitor every group and component definition and the model object. I'm not that familiar with the overhead of Observers. But this sounds like it'd be quite a lot of observers running...
                        Anyone knows what the performance impact of doing this would be?

                        I think it's a worthwhile experiment to create a meta-observer (built on the existing observers) that watches a "class" of entities - such as a GroupsObserver, or something like that.

                        Hi

                        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