Hi,
In my module, I create a folder using the following code:
@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:
@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:
- Go to the Data Module.
- Check the “Show MRML ID” box,
- Toggle the visibility On then OFF then ON again
- Then run the code for removing
Is there a way that I can execute this without resorting to this 4 step hack?