# How to use observer?

**URL:** https://discourse.slicer.org/t/how-to-use-observer/29526
**Category:** Development
**Tags:** python
**Created:** [May 18, 2023, 7:07am UTC](https://discourse.slicer.org/t/how-to-use-observer/29526 "2023-05-18T07:07:56Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![dsa934](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/dsa934/32/17907_2.png) [@dsa934](https://discourse.slicer.org/u/dsa934)
#### Post date: [May 18, 2023, 7:07am UTC](https://discourse.slicer.org/t/how-to-use-observer/29526/1 "2023-05-18T07:07:56Z")

</div>

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.

 ![image](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/e/e/ee77ba215786717d2bdd7517e78d0386f1541e14.png)  
(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?

---

<div class="post-metadata">

### Author: ![lassoan](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lassoan/32/13_2.png) [@lassoan](https://discourse.slicer.org/u/lassoan)
#### Post date: [May 18, 2023, 7:14pm UTC](https://discourse.slicer.org/t/how-to-use-observer/29526/2 "2023-05-18T19:14:34Z")

</div>

You can add observers to the scene - so that you [get a notification when a new node is added](https://slicer.readthedocs.io/en/latest/developer_guide/script_repository.html#show-volume-rendering-automatically-when-a-volume-is-loaded); or to a markup node - so that you get a notification when [points are modified or interaction with a point is finished](https://slicer.readthedocs.io/en/latest/developer_guide/script_repository.html#get-a-notification-if-a-markup-control-point-position-is-modified). Check out [developer tutorials](https://slicer.readthedocs.io/en/latest/developer_guide/api.html#tutorials) and examples in the [script repository](https://slicer.readthedocs.io/en/latest/developer_guide/script_repository.html#get-a-notification-if-a-markup-control-point-position-is-modified).
