# Deletion of "vtkMRMLFolderDisplayNode"

**URL:** <https://discourse.slicer.org/t/deletion-of-vtkmrmlfolderdisplaynode/35072>\
**Category:** Development\
**Created:** [March 25, 2024, 7:54pm UTC](https://discourse.slicer.org/t/deletion-of-vtkmrmlfolderdisplaynode/35072 "2024-03-25T19:54:02Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Aamir\_Khan1](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/aamir_khan1/32/68485_2.png) [@Aamir\_Khan1](https://discourse.slicer.org/u/Aamir_Khan1)\
**Post date:** [March 25, 2024, 7:54pm UTC](https://discourse.slicer.org/t/deletion-of-vtkmrmlfolderdisplaynode/35072/1 "2024-03-25T19:54:02Z")

</div>

Hi,

In my module, I create a folder using the following code:

```auto
    @staticmethod
    def create_folder_item_in_subject_hierarchy(serial_number):
        shNode = slicer.vtkMRMLSubjectHierarchyNode.GetSubjectHierarchyNode(slicer.mrmlScene)
        folder_name = serial_number + 'models'
        exportFolderItemId = shNode.CreateFolderItem(shNode.GetSceneItemID(), folder_name)
        return exportFolderItemId

```

Then after performing some manipulations, I delete this folder using the following code:

```auto
    @staticmethod
    def remove_folder_display_node() -> None:
       # folderDisplayNode = slicer.mrmlScene.GetFirstNodeByClass("vtkMRMLFolderDisplayNode")
        folderDisplayNode = slicer.util.getNodesByClass("vtkMRMLFolderDisplayNode")

        for node in folderDisplayNode:
            slicer.mrmlScene.RemoveNode(node)

```

The problem is that it doesn’t works.

It works after:

1. Go to the Data Module.
2. Check the “Show MRML ID” box,
3. Toggle the visibility On then OFF then ON again
4. Then run the code for removing

Is there a way that I can execute this without resorting to this 4 step hack?

---

<div class="post-metadata">

**Author:** ![cpinter](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/cpinter/32/7995_2.png) [@cpinter](https://discourse.slicer.org/u/cpinter)\
**Post date:** [April 1, 2024, 12:10pm UTC](https://discourse.slicer.org/t/deletion-of-vtkmrmlfolderdisplaynode/35072/2 "2024-04-01T12:10:57Z")

</div>

> [@Aamir\_Khan1](#):
>
> `vtkMRMLFolderDisplayNode`

The folder display node is only created if the user uses the show/hide function of the folder, or creates the display node explicitly (btw I’m pretty sure step 2 is not necessary).

To create the folder display node explicitly you can call this function

> <https://github.com/Slicer/Slicer/blob/3903a95c38730e522630569b114825dd0d7c9532/Modules/Loadable/Models/Widgets/qMRMLModelDisplayNodeWidget.cxx#L323-L329>
