API change in SubjectHierarchyNode?

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

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

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")

I did a complete overhaul of SlicerCIP to SH 2.0 right when I integrated the new SH to Slicer, see branch. This might help.

Also https://www.slicer.org/wiki/Documentation/Nightly/ScriptRepository#Get_subject_hierarchy_item

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

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!

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