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

    [observer issue] onEraseEntities not working?

    Scheduled Pinned Locked Moved Developers' Forum
    4 Posts 4 Posters 235 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.
    • dereiD Offline
      derei
      last edited by

      **I made some tests with EntityObserver and EntitiesObserver classes and it looks like onEraseEntities method doesn't work, or I don't know how to use it?
      I tried the same thing with onEraseEntity and it works.

      This didn't worked. Nothing happens

      
      class MyEntitiesObserver < Sketchup;;EntitiesObserver
      	def onEraseEntities(entities)
      		puts "Erased; " + entities.to_s
      	end
      end
      
      begin
      x = 0
      	Sketchup.active_model.entities.each do |e|
      			e.add_observer(MyEntitiesObserver.new)
      			x += 1
      	end
      	puts 'Observer was added to ' + x.to_s + ' elements.'
      end
      
      

      This told me what I wanted to see:

      
      class MyEntityObserver < Sketchup;;EntityObserver
      	def onEraseEntity(ent)
      		puts "Erased; " + ent.to_s
      	end
      end
      
      begin
      x = 0
      	Sketchup.active_model.entities.each do |e|
      		e.add_observer(MyEntityObserver.new)
      		x += 1
      	end
      	puts 'Observer was added to ' + x.to_s + ' elements.'
      end
      
      ```**

      DESIGNER AND ARTIST [DEREI.UK](http://derei.uk/l)

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

        I've not had that event working either. The EntitiesObserver has been trouble since the beginning.
        What SketchUp version are you testing on? There has been some changes in SU8.

        See this chart where I've tried to map the functionality of each event in the various SU versions: http://www.thomthom.net/software/sketchup/observers/#EntitiesObserver
        (Note that the chart is probably not 100% accurate so if you have more info I'd be very interested in this.)

        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
          morph
          last edited by

          to thomthom

          I interest to use EntitiesObserver.onElementModified or EntityObserver.onChangeEntity to check face entity has modified or not?

          But after I read the illustrate under both method from https://developers.google.com/sketchup/docs/ourdoc/entitiesobserver ("The onElementModified method is invoked whenever one or more elements in the collection are modified.") and https://developers.google.com/sketchup/docs/ourdoc/entityobserver ("The onChangeEntity method is invoked when your entity is modified.")

          I can not understand the scope of meaning of modified state of face entity. The word "modified" mean scaling, moving, reverse, split or more. I am new in programming, please suggestion.

          Hope you will understand my question?

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

            That's interesting.. I did not realize we could make code blocks have smaller text.

            I'm not here much anymore.

            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