# Toggle visibility of models in a folder using scripting

**URL:** <https://discourse.slicer.org/t/toggle-visibility-of-models-in-a-folder-using-scripting/32497>\
**Category:** Development\
**Tags:** python\
**Created:** [October 31, 2023, 5:23am UTC](https://discourse.slicer.org/t/toggle-visibility-of-models-in-a-folder-using-scripting/32497 "2023-10-31T05:23:52Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Chris\_Klink](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/chris_klink/32/68070_2.png) [@Chris\_Klink](https://discourse.slicer.org/u/Chris_Klink)\
**Post date:** [October 31, 2023, 5:23am UTC](https://discourse.slicer.org/t/toggle-visibility-of-models-in-a-folder-using-scripting/32497/1 "2023-10-31T05:23:52Z")

</div>

Hi Experts,  
I’m trying to toggle the visibility of individual models inside a folder from a Python script. I can toggle the visibility of the entire folder, but all examples I can find of how to loop over the children don’t work because the display folder object does not have a get children or getnumberofchildren attribute. I must be overlooking something obvious and would appreciate some pointers.  
Thanks!  
Chris

---

<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:** [November 1, 2023, 2:57pm UTC](https://discourse.slicer.org/t/toggle-visibility-of-models-in-a-folder-using-scripting/32497/2 "2023-11-01T14:57:39Z")

</div>

The folder display node is a MRML node. It does not know how to iterate through the subject hierarchy. Instead, you can:

- get the subject hierarchy node
- get the subject hierarchy item ID corresponding to the folder display node
- use the subject hierarchy node to iterate through children of that subject hierarchy item using its ID
