I have an extension where we create our products(
ComponentInstance) from a
UI::HtmlDialog has images, on clicking the image we create a 3D model. This
UI::HtmlDialog also has tabs. One of the tabs is edit, which shows properties on the selected 3D model. The user can update these values, which will reflect in the 3D model.
I have a
SelectionObserver which I attach to selection like this
Sketchup.active_model.selection.add_observer whenever a new product is created or loaded from a saved file.
During the update operation I mentioned above(From
- I remove the observer using
- Update the 3D model
- I add back the observer
Note: I only maintain only one observer instance
def remove_product_selection_observer Sketchup.active_model.selection.remove_observer(@@product_selection_observer) end def add_product_selection_observer if(@@product_selection_observer == nil) @@product_selection_observer = ProductSelectionObserver.new end Sketchup.active_model.selection.add_observer(@@product_selection_observer) end
- Create a 3D model from
UI::HtmlDialog. Call it ‘product 1’
- Create another 3D model from
UI::HtmlDialog. Call it ‘product 2’
- Now switch the tab in
UI::HtmlDialogto edit(edits ‘product 2’). Update some properties.
Point 3 code basically looks like this
product.remove_product_selection_observer product.update(updated_properties) product.add_product_selection_observer
Now when I select ‘product 1’ none of the methods in the observer gets fired. I rely on these observer events to figure out that a different product is selected and based on that I send the selected product properties to
Q: Why the selectionObserver method is not getting triggered?
Is there any better way to debug than just making sure the observer is attached and the observer’s methods are fired?
P.S: After point 2 in the use case, if I double click on my product(componentInstance), I start getting observer events fired correctly.
How can I debug this further to figure out why my observer is not firing events.