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.
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better π
Register LoginAdvertisement