Hi,
In my extension, in some context, I need to reset a transform to Identity, without changing its node otherwise (that is, I need to keep its state wrt volumes, display-nodes etc). When I first wrote this, a few years ago, I found an effective way to do this was by calling
transformNode.GetTransformToParent().Identity()
But recently, I found that (at least as of Slicer 5.8.1, maybe even before that) there’s a problem with this: afterslicer.mrmlScene.AddNewNodeByClass("vtkMRMLTransformNode"), the transform to parent is not initialized, and transformNode.GetTransformToParent() returns None.
An obvious workaround is:
if to_parent := transformNode.GetTransformToParent():
to_parent.Identity()
But it feels dirty. Is there a cleaner way?