Set a node as a parent for the other nodes


How to setup vtkMRMLRTBeamNode as a parent node for a other nodes (e.g., vtkMRMLTableNode)?

The beam node observed some table node, and in the hierarchy tree view widget the drag-and-drop operation allows to put table node as a child the beam node, but how to do same thing using C++?

The code like: shNode->SetItemParent( tableNodeId, beamNodeId) doesn’t work even if all item IDs are valid.

The result should look like on the After picture.



SetItemParent method should work well. Use subject hierarchy item IDs (not MRML node IDs) as inputs. Make sure you use latest stable or latest preview release.

Could it be that batch process state of the scene prevent such operation? It works well after scene->EndState(vtkMRMLScene::BatchProcessState);.

There are limited or no widget updates while in batch processing state, but after batch processing ends, all the pending changes should be applied.