sketchucation logo sketchucation
    • Login
    ℹ️ Licensed Extensions | FredoBatch, ElevationProfile, FredoSketch, LayOps, MatSim and Pic2Shape will require license from Sept 1st More Info

    [ruby doc] entity observers and observers in general

    Scheduled Pinned Locked Moved Developers' Forum
    5 Posts 3 Posters 752 Views 3 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.
    • W Offline
      Whaat
      last edited by

      class MyEntityObserver <  Sketchup;;EntityObserver
       	def onEntityChanged (entity)
      		p entity
      
      		# do something
      
      	end
      
      end
      
      def observe_ent()
      
      ent=Sketchup.active_model.selection.first
      ent.add_observer MyEntityObserver.new
      
      end
      

      For the life of me, I can't seem to get 'onEntityChanged' to get called. Is this a bug or what? The documentation for all of the observer classes is pathetic. I would like every class of observer to have a detailed description of what has to happen for their methods to be called. In this example, what change must be made to the entity for the 'onEntityChanged' method to get called? If I ever figure it out, I'll let you know.

      Thanks for working on this Todd!

      @unknownuser said:

      # In your code. If the face changes, MyEntityObserver is called.
      > 
      > face.add_observer(MyEntityObserver.new)             
      >    
      

      SketchUp Plugins for Professionals

      1 Reply Last reply Reply Quote 0
      • Didier BurD Offline
        Didier Bur
        last edited by

        Hi Whaat,
        Have a look here:
        http://www.sketchucation.com/forums/scf/viewtopic.php?f=57&t=3282&p=16071&hilit=observer#p16071

        DB

        1 Reply Last reply Reply Quote 0
        • T Offline
          todd burch
          last edited by

          I agree Whaat. But, please come back with a solution to the problem, then I'll update the doc. (Other's can provide the solution too, of course)

          Todd

          1 Reply Last reply Reply Quote 0
          • W Offline
            Whaat
            last edited by

            It seems like the problem is that the name of the method is wrong in the API docs. It should be 'onChangeEntity' not 'onEntityChanged'.

            This should be updated in the docs.

            EDIT: on closer inspection, the method is only wrong in the example at the top of the page. The correct method is shown on the page near the bottom. (It is confusing though)

            SketchUp Plugins for Professionals

            1 Reply Last reply Reply Quote 0
            • T Offline
              todd burch
              last edited by

              OK. I have fixed the "example" (if you could call it that) at the top of the EntityObserver file. I think I have an example somewhere I might could clean up and add to it.

              The same "bad example" is in other observer files too. I'll get to those as topics come up for inclusion.

              What's really needed for the observers, and I can start on it, is some "big picture" concept information.

              Thanks!

              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