Edge observer
- 
 Hello, For one of my plugin, I want to catch when a component is modified (ie entities inside the component are moved, stretched, erased, added, etc). My problem is to trigger an observer when moving an edge (single edge not attached to a face) using moving tool. Do do so, I placed an observer on model to catch when the active path is changed, and then add on observer on entities within active_entities : class MyModelObserver < Sketchup;;ModelObserver @@observers = {} @@previous_path=nil def onActivePathChanged(model) puts "onActivePathChanged "+Sketchup.active_model.active_entities.to_s #remove previous observer if exist if @@previous_path!=nil then puts "Remove observers of "+@@previous_path.to_s p @@previous_path.remove_observer(@@observers[@@previous_path]) @@previous_path=nil end #Quit if active_path is nill (no group or component is opened) return if !Sketchup.active_model.active_path #define observer object and try to add it to active_entities #if it is successfully added, update class variable @@observers observer = MyEntitiesObserver.new() if Sketchup.active_model.active_entities.add_observer(observer) #Save observers data @@observers[Sketchup.active_model.active_entities] = observer @@previous_path=Sketchup.active_model.active_entities #Add observers to each entity of active_entities for entity in Sketchup.active_model.active_entities entity.add_observer(MyEntityObserver.new) end end end end class MyEntityObserver < Sketchup;;EntityObserver def onEraseEntity(entity) puts "onEraseEntity; #{entity}" end def onChangeEntity(entity) puts "onChangeEntity; #{entity}" end end class MyEntitiesObserver < Sketchup;;EntitiesObserver def onElementAdded(entities, entity) puts "onElementAdded " end def onElementModified(entities, entity) puts "onElementModified " end def onElementRemoved(entities, entity_id) puts "onElementRemoved" end def onEraseEntities(entities) puts "onEraseEntities" end def onChangeEntity(entity) puts "onChangeEntity; #{entity}" end endThen running the script : Sketchup.active_model.add_observer(MyModelObserver.new)I cannot see any "modification" observer triggers when when moving a simple edge not attached to a face, within a component... If someone can help me... 
 Inteloide
- 
 Well, a start of explaination and solution, here : 
 http://forums.sketchup.com/t/edge-change-observer/8184 :Put an observer on edge.start and edge.end Thanks TT ! 
Advertisement

 
                             
                             
                             
                             
                             
                             
                            