# How to get volume and model in the scene in the python code？

**URL:** https://discourse.slicer.org/t/how-to-get-volume-and-model-in-the-scene-in-the-python-code/11360
**Category:** Development
**Created:** [April 30, 2020, 6:22am UTC](https://discourse.slicer.org/t/how-to-get-volume-and-model-in-the-scene-in-the-python-code/11360 "2020-04-30T06:22:31Z")
**Posts on this page:** 2
**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 30, 2020, 6:22am UTC](https://discourse.slicer.org/t/how-to-get-volume-and-model-in-the-scene-in-the-python-code/11360/1 "2020-04-30T06:22:31Z")

</div>

I loaded a volume, in the scene and created a model. Below the data tree structure you can see the data shown in the figure. i want to get them in python code,The following:  
model = slicer.mrmlScene.GetNumberOfNodesByClass(“vtkMRMLModelHierarchyNode”)  
volume = slicer.mrmlScene.GetNumberOfNodesByClass(“vtkMRMLVolumeHeaderlessStorageNode”)  
Is it possible to do this, but I test seems to have some problems, can you solve it? Thank you!

 ![图片](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/a/1/a12faf57999da04bf278beb83609f4c1dfbf56bd.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 30, 2020, 9:05pm UTC](https://discourse.slicer.org/t/how-to-get-volume-and-model-in-the-scene-in-the-python-code/11360/2 "2020-04-30T21:05:36Z")

</div>

If you put a subject hierarchy tree widget into your module, you can get the current selection by calling [currentItem()](http://apidocs.slicer.org/master/classqMRMLSubjectHierarchyTreeView.html#a696587e7f872d3221151658252dd0920).
