Set linear transform parameter via python

Hi all,
I would like to set and control a linear transformation from python.

I created a linear transformation via the module GUI and then I changed a parameter (just to do a test).
If I run this code nothing changes in the GUI (I would expect a reset to an identity matrix):

t = slicer.mrmlScene.GetFirstNodeByName(“LinearTransform”)
m = vtk.vtkMatrix4x4()
t.SetMatrixTransformToParent(m)

Of course I am missing something!
Thanks a lot.

Paolo

What you do is correct.

Maybe slicer.mrmlScene.GetFirstNodeByName() does not return you the transform that you expect because you have multiple transforms by that name in the scene.

If I use GetNOdeByID it works, but it’s strange, because I’m trying this into an empty scene.

By default, 3 transforms are created for some built-in nodes (cameras or slices). But other modules can create transforms by using any names any time, so GetFirstNodeByName is only recommended for debugging or testing.

Thanks @lassoan,
I’ll go for the ID, much safer.

Paolo