ℹ️ Licensed Extensions | FredoBatch, ElevationProfile, FredoSketch, LayOps, MatSim and Pic2Shape will require license from Sept 1st More Info
Adding observers to a group of entities
-
Has anyone had trouble adding observers to a group of entities?
It seems to add the observers just fine, but when I try to remove them, it only is able to remove the first entity in the group. Also, if I try remove, then add any observers, it never adds the observers.
-
can you paste the code you use to add and remove the observers?
-
Here is an abridged version:
class EntityObserver def onChangeEntity(entity) puts entity.to_s + " changed" end end $entityObserver = EntityObserver.new def addObserver Sketchup.active_model.selection.each{|entity| entity.add_observer($entityObserver)} end def removeObserver Sketchup.active_model.selection.each{|entity| entity.remove_observer($entityObserver)} endIf you have one entity selected, it adds and removes fine, but if you have more than one entity selected, it only removes the first entity in the selection.
Advertisement