# How to get current volume and model selection using Python

**URL:** https://discourse.slicer.org/t/how-to-get-current-volume-and-model-selection-using-python/11325
**Category:** Development
**Created:** [April 28, 2020, 6:14am UTC](https://discourse.slicer.org/t/how-to-get-current-volume-and-model-selection-using-python/11325 "2020-04-28T06:14:49Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![Shicong](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/shicong/32/6562_2.png) [@Shicong](https://discourse.slicer.org/u/Shicong)
#### Post date: [April 28, 2020, 6:14am UTC](https://discourse.slicer.org/t/how-to-get-current-volume-and-model-selection-using-python/11325/1 "2020-04-28T06:14:50Z")

</div>

It’s the default not on the volumeclipwithmodel “, the display is “select a volume” , without the mouse select. I want to get the active volume object of the volumes module from the python code, and the current model object of the module. Note that I am going to get volume and model objects in the python code, can you provide the code? Thanks so much! !!!  
 ![图片](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/7/a/7a2fa87d951ad8d680f5ac843d580206b4c45855.png)

 ![图片](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/d/4/d46a987061d0f74dc1ad9925dd4befcc70d06c94.png)  
 ![图片](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/9/1/914416c9071e59484c7f11d88716492b12dea189.png)

---

<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: [April 28, 2020, 2:00pm UTC](https://discourse.slicer.org/t/how-to-get-current-volume-and-model-selection-using-python/11325/2 "2020-04-28T14:00:13Z")

</div>

You can access every widget of every module using `slicer.util.findChild()` function, but this should only be used for testing or diagnostics, not for implementing end-user workflows.

Your module should not depend on what nodes are selected to be edited in other module’s GUI. Doing this would severely restrict what you can do in Slicer (modules would keep interfering with each other and ultimately many things would be just impossible to do).

Instead, you put node selectors and various editing widgets into the GUI of your module. Module user interfaces are typically built from reusable widgets, so you can easily put together a GUI that is a combination of several other modules.

---

<div class="post-metadata">

### Author: ![Shicong](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/shicong/32/6562_2.png) [@Shicong](https://discourse.slicer.org/u/Shicong)
#### Post date: [April 29, 2020, 6:50am UTC](https://discourse.slicer.org/t/how-to-get-current-volume-and-model-selection-using-python/11325/3 "2020-04-29T06:50:21Z")

</div>

Thank you for your answer 😃
