[observer issue] onEraseEntities not working?
-
**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 ```**
-
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.) -
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?
-
That's interesting.. I did not realize we could make code blocks have smaller text.
Advertisement