# API change in SubjectHierarchyNode?

**URL:** https://discourse.slicer.org/t/api-change-in-subjecthierarchynode/838
**Category:** Development
**Created:** [August 7, 2017, 11:27pm UTC](https://discourse.slicer.org/t/api-change-in-subjecthierarchynode/838 "2017-08-07T23:27:01Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![jonieva](https://avatars.discourse-cdn.com/v4/letter/j/91b2a8/32.png) [@jonieva](https://discourse.slicer.org/u/jonieva)
#### Post date: [August 7, 2017, 11:27pm UTC](https://discourse.slicer.org/t/api-change-in-subjecthierarchynode/838/1 "2017-08-07T23:27:01Z")

</div>

I’m getting an error when trying to access the HierarchyNode corresponding to the MRLMScene node.  
I’m doing:

```auto
shNode = slicer.vtkMRMLSubjectHierarchyNode.GetSubjectHierarchyNode(slicer.mrmlScene)

```

which was working fine.

Was there any change in the API?

This is happening even in the 4.6.2 stable Release, which is weird because I tested my module long ago and it was working fine.

Is it possible that there is any old cached setting that can make trouble?  
In any case, what would be the correct way to access this node now?

Thank you.

Jorge

---

<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: [August 7, 2017, 11:47pm UTC](https://discourse.slicer.org/t/api-change-in-subjecthierarchynode/838/2 "2017-08-07T23:47:06Z")

</div>

SubjectHierarchy was reworked a couple of months ago to make it much more efficient (so users do not need to explicitly enable it anymore). I would suggest to use a recent nightly build.

If you enter this into the Python console then a folder should appear in the Subject Hierarchy tab of the Data module:

```
shNode = slicer.vtkMRMLSubjectHierarchyNode.GetSubjectHierarchyNode(slicer.mrmlScene)
shNode.CreateFolderItem(shNode.GetSceneItemID(),"MyFirstFolder")
```

---

<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: [August 8, 2017, 12:21am UTC](https://discourse.slicer.org/t/api-change-in-subjecthierarchynode/838/3 "2017-08-08T00:21:51Z")

</div>

I did a complete overhaul of SlicerCIP to SH 2.0 right when I integrated the new SH to Slicer, see [branch](https://github.com/cpinter/SlicerCIP/commits/subject-hierarchy-20). This might help.

---

<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: [August 8, 2017, 12:23am UTC](https://discourse.slicer.org/t/api-change-in-subjecthierarchynode/838/4 "2017-08-08T00:23:32Z")

</div>

Also [https://www.slicer.org/wiki/Documentation/Nightly/ScriptRepository#Get\_subject\_hierarchy\_item](https://www.slicer.org/wiki/Documentation/Nightly/ScriptRepository#Get_subject_hierarchy_item)

---

<div class="post-metadata">

### Author: ![fedorov](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/fedorov/32/14_2.png) [@fedorov](https://discourse.slicer.org/u/fedorov)
#### Post date: [August 8, 2017, 1:46am UTC](https://discourse.slicer.org/t/api-change-in-subjecthierarchynode/838/5 "2017-08-08T01:46:24Z")

</div>

> [@jonieva](#):
>
> This is happening even in the 4.6.2 stable Release

We ran into this issue while trying to use CIP extension in 4.6.2 stable build, which was released in Nov 2016.

---

<div class="post-metadata">

### Author: ![jonieva](https://avatars.discourse-cdn.com/v4/letter/j/91b2a8/32.png) [@jonieva](https://discourse.slicer.org/u/jonieva)
#### Post date: [August 8, 2017, 1:35pm UTC](https://discourse.slicer.org/t/api-change-in-subjecthierarchynode/838/6 "2017-08-08T13:35:04Z")

</div>

Thanks for your answers.  
@cpinter I’m sorry I thought that SH 2.0 had been integrated into the Slicer 4.6.2 release. Let’s hope there’s a new release soon!

---

<div class="post-metadata">

### Author: ![jumbojing](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/jumbojing/32/10811_2.png) [@jumbojing](https://discourse.slicer.org/u/jumbojing)
#### Post date: [December 15, 2021, 3:55am UTC](https://discourse.slicer.org/t/api-change-in-subjecthierarchynode/838/7 "2021-12-15T03:55:31Z")

</div>

> [@cpinter](#):
>
> branch

How to remove the SubjectHierarchyNode (e.g. folder)and its items?
