# Resetting a transform in an existing node

**URL:** <https://discourse.slicer.org/t/resetting-a-transform-in-an-existing-node/48040>\
**Category:** Development\
**Created:** [September 2, 2026, 1:58pm UTC](https://discourse.slicer.org/t/resetting-a-transform-in-an-existing-node/48040 "2026-09-02T13:58:00Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![shai-ikko](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/shai-ikko/32/15765_2.png) [@shai-ikko](https://discourse.slicer.org/u/shai-ikko)\
**Post date:** [September 2, 2026, 1:58pm UTC](https://discourse.slicer.org/t/resetting-a-transform-in-an-existing-node/48040/1 "2026-09-02T13:58:00Z")

</div>

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

```python
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: after`slicer.mrmlScene.AddNewNodeByClass("vtkMRMLTransformNode")`, the transform to parent is not initialized, and `transformNode.GetTransformToParent()` returns `None`.

An obvious workaround is:

```python
if to_parent := transformNode.GetTransformToParent():
    to_parent.Identity()

```

But it feels dirty. Is there a cleaner way?

---

<div class="post-metadata">

**Author:** ![Sunderlandkyl](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/sunderlandkyl/32/79987_2.png) [@Sunderlandkyl](https://discourse.slicer.org/u/Sunderlandkyl)\
**Post date:** [September 2, 2026, 3:02pm UTC](https://discourse.slicer.org/t/resetting-a-transform-in-an-existing-node/48040/2 "2026-09-02T15:02:19Z")

</div>

You can set the transform matrix to identity with:

```auto
transformNode.SetMatrixTransformToParent(vtk.vtkMatrix4x4())

```

This is the way that it’s done from the transform module widget: [Slicer/Modules/Loadable/Transforms/qSlicerTransformsModuleWidget.cxx at feeb45346728c3a37115783aa40e03da3bfb2bf2 · Slicer/Slicer · GitHub](https://github.com/Slicer/Slicer/blob/feeb45346728c3a37115783aa40e03da3bfb2bf2/Modules/Loadable/Transforms/qSlicerTransformsModuleWidget.cxx#L478-L479)
