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

Observers !

Scheduled Pinned Locked Moved Developers' Forum
20 Posts 6 Posters 3.4k Views 6 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 2 Apr 2009, 08:47

    Check out the new APi docs instead: http://code.google.com/intl/nb/apis/sketchup/docs/ourdoc/modelobserver.html

    ModelObserver.OnTransactionEnd doesn't exist as you see in the new docs. I also poked around in the class just to make sure it was missed from the docs, and this is the only events:

    
    onActivePathChanged
    onAfterComponentSaveAs
    onBeforeComponentSaveAs
    onDeleteModel
    onEraseAll
    onExplode
    onPlaceComponent
    onSaveModel
    onTransactionAbort
    onTransactionCommit
    onTransactionEmpty
    onTransactionRedo
    onTransactionStart
    onTransactionUndo
    
    

    On a sidenote: I've come across a few observers that doesn't work. I've reported them in this thread: http://www.sketchucation.com/forums/scf/viewtopic.php?f=180&t=17047

    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 2 Apr 2009, 08:51

      I think ModelObserver.onTransactionCommit is the event you want.

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

      1 Reply Last reply Reply Quote 0
      • M Offline
        Matt666
        last edited by 2 Apr 2009, 09:47

        Hi thomthom! And thank you for your quisk answers! πŸ˜„

        I have a matter with all onTransaction.... I don't know how to use them... 😳
        The problem is I get a bug splat with because of entities created/modified by ruby. Why can these functions (onTransaction...) help me???
        Therefore, The questions are :

        • Is these functions can stop bug splat with Test.start_E?
        • Can I return class of an entity modified/created by ruby, qith entity-observers functions?

        Frenglish at its best !
        My scripts

        1 Reply Last reply Reply Quote 0
        • T Offline
          thomthom
          last edited by 2 Apr 2009, 10:27

          You can use that to detect when a plugin starts and commits and operation. Holding of your own actions until the operation is complete. If I understand this right, that's what might be causing the problems.

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

          1 Reply Last reply Reply Quote 0
          • M Offline
            Matt666
            last edited by 2 Apr 2009, 12:18

            Ok, thank you Thomthom. I see how these functions could help me.

            I try with code below, and none of onTransaction... functions works... Is it normal... Am I stupid? πŸ˜„
            I really really don't understand the matter...
            Can you help me thomthom, please???

            Thank you!


            EntitiesObserverTest.rb

            Frenglish at its best !
            My scripts

            1 Reply Last reply Reply Quote 0
            • T Offline
              thomthom
              last edited by 2 Apr 2009, 12:54

              I haven't used the transaction events myself yet. Can't give an answer from the top of my head. I'd have to poke around first. I hope they are all working. I thought they might be useful for a plugin I'm doing myself.

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

              1 Reply Last reply Reply Quote 0
              • M Offline
                Matt666
                last edited by 3 Apr 2009, 07:32

                Ok thank you thomthom! I'm trying with other ways, I'll tell you if they work...
                πŸ˜‰

                Frenglish at its best !
                My scripts

                1 Reply Last reply Reply Quote 0
                • H Offline
                  HPW
                  last edited by 3 Apr 2009, 13:47

                  Are the here metioned observers helpfull to get a OnImport event?
                  I would be intrerested to start a houskeeping script whenever I import one of our Autocad.DWG
                  (Making a layer purge/layer switching and building groups from hierarchy-info contained in blocknames)

                  1 Reply Last reply Reply Quote 0
                  • T Offline
                    TIG Moderator
                    last edited by 3 Apr 2009, 14:45

                    @hpw said:

                    Are the here metioned observers helpfull to get a OnImport event?
                    I would be intrerested to start a houskeeping script whenever I import one of our Autocad.DWG
                    (Making a layer purge/layer switching and building groups from hierarchy-info contained in blocknames)

                    Sounds like your rewriting parts of my XrefManager for me ?

                    TIG

                    1 Reply Last reply Reply Quote 0
                    • H Offline
                      HPW
                      last edited by 3 Apr 2009, 19:11

                      @unknownuser said:

                      Sounds like your rewriting parts of my XrefManager for me ?

                      Nope, we have a block-structure of artikels with a master-slave relation ship build on EED-Data which gets lost during export/import. (As far as I know, or does Sketchup supports EED?)
                      And it would make sense to rebuild the structure on a group-base.
                      I found your nice ComponentReporter+.rb here and get the list of imported components.
                      Now I have to start with ruby (My main language ist still autolisp) and have to parse the component-names to lists and get some group building code to work with the components which belong to the new group (which then must be named with the same name as the first entry).

                      So still lots to learn!

                      Hans-Peter

                      1 Reply Last reply Reply Quote 0
                      • T Offline
                        TIG Moderator
                        last edited by 4 Apr 2009, 09:02

                        Almost anything in SUp can be given 'attributes' =~ 'extended data' ?
                        You could export the blocks' xdata from AutoCAD using AutoLisp: putting it into a .csv file that'd list the block-name/instance/location/xdata etc...
                        Then you could write a matching Ruby to use on it later...
                        After importing the AutoCAD file, its various blocks will come in as components - they should keep the same names and relative positions etc.
                        Run the Ruby on the corresponding .csv file and add the xdata into each matching component-definition/instance as attributes.
                        If the blocks interact you need to write a Ruby that perhaps 'observes' instances and finds/reads/writes the appropriate corresponding attributes and takes the required actions etc etc...
                        At least if you have AutoLisp experience exporting the xdata in a usable format for Ruby would be relatively straightforward...

                        TIG

                        1 Reply Last reply Reply Quote 0
                        • H Offline
                          HPW
                          last edited by 4 Apr 2009, 11:46

                          @unknownuser said:

                          At least if you have AutoLisp experience exporting the xdata in a usable format for Ruby would be relatively straightforward...

                          Thanks for your thoughts about extending such interface.
                          I had thought about this for myself, but I have to make steps one after another.
                          So first I want to get the structure in place again and then I can thought about adding/transporting more Info.
                          The AutoLisp experience is not the problem, since I am a nearly full-time autolisp-developer and I am really used to do anything with ExtendedEntityData.

                          We have logical propertys and geometric propertys stored in EED and even small chunks of Lisp-code stored there, which gets fired under certain events.

                          So I can imagine I could do similar things in the future with ruby.

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

                          Advertisement