How to use observer?

Operating system: window 10
Slicer version: 5.2.1

Whenever a new node is added to the scene, I know that observer is used to process the function for the added node.


(ref: Stanford bunny)

I would like to implement a function that prevents the currently selected markups point in the Bunny mesh from exceeding the range of the Bunny mesh.

In order to perform the above process, it seems that the markupsNode needs to be accessible every time it is added to secne. Is there a way?

Any ideas how to prevent the markupsNode from going beyond the bounds of the mesh?

You can add observers to the scene - so that you get a notification when a new node is added; or to a markup node - so that you get a notification when points are modified or interaction with a point is finished. Check out developer tutorials and examples in the script repository.

1 Like