# The problem between Node and vtkProp3D

**URL:** <https://discourse.slicer.org/t/the-problem-between-node-and-vtkprop3d/5526>\
**Category:** Development\
**Created:** [January 27, 2019, 6:23am UTC](https://discourse.slicer.org/t/the-problem-between-node-and-vtkprop3d/5526 "2019-01-27T06:23:05Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![timeanddoctor](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/timeanddoctor/32/5839_2.png) [@timeanddoctor](https://discourse.slicer.org/u/timeanddoctor)\
**Post date:** [January 27, 2019, 6:23am UTC](https://discourse.slicer.org/t/the-problem-between-node-and-vtkprop3d/5526/1 "2019-01-27T06:23:05Z")

</div>

I want to use a vtkAssembly in slicer. I am not clear there is any relationship between modelNode and vtkProp3D. How to use a model as vtkProp3D in slicer script.  
`Assembly.AddPart(NeedleModel)`  
Traceback (most recent call last): File “”, line 1, in TypeError: AddPart argument 1: method requires a vtkProp3D, a vtkMRMLModelNode was provided.  
And another problem is how to rotate a model(or transform) setting a origin(x,y,z) myself.  
Thank you very much.

---

<div class="post-metadata">

**Author:** ![lassoan](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lassoan/32/13_2.png) [@lassoan](https://discourse.slicer.org/u/lassoan)\
**Post date:** [January 27, 2019, 2:57pm UTC](https://discourse.slicer.org/t/the-problem-between-node-and-vtkprop3d/5526/2 "2019-01-27T14:57:49Z")

</div>

Each model node is displayed using a prop in each view. You should not need assembly, as you can build your own model transform hierarchy using transform and model nodes.

---

<div class="post-metadata">

**Author:** ![timeanddoctor](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/timeanddoctor/32/5839_2.png) [@timeanddoctor](https://discourse.slicer.org/u/timeanddoctor)\
**Post date:** [January 27, 2019, 3:30pm UTC](https://discourse.slicer.org/t/the-problem-between-node-and-vtkprop3d/5526/3 "2019-01-27T15:30:14Z")

</div>

Thank you Professor Lassoan.  
I need add two parts into a Transform, and then I need set a Origin for this transform. Are there any example similar what I am doing.  
Thanks.

---

<div class="post-metadata">

**Author:** ![lassoan](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lassoan/32/13_2.png) [@lassoan](https://discourse.slicer.org/u/lassoan)\
**Post date:** [January 27, 2019, 4:44pm UTC](https://discourse.slicer.org/t/the-problem-between-node-and-vtkprop3d/5526/4 "2019-01-27T16:44:06Z")

</div>

You just need to create transform nodes and apply it to model and transform nodes below. [SlicerIGT tutorials](http://www.slicerigt.org/wp/user-tutorial/) may help - see for example U-04.

---

<div class="post-metadata">

**Author:** ![timeanddoctor](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/timeanddoctor/32/5839_2.png) [@timeanddoctor](https://discourse.slicer.org/u/timeanddoctor)\
**Post date:** [January 28, 2019, 2:15am UTC](https://discourse.slicer.org/t/the-problem-between-node-and-vtkprop3d/5526/5 "2019-01-28T02:15:41Z")

</div>

Thank you for your quick reply.  
I can do it through manu now. In order to run it through script, I found some code from here, but I could not distinguish the different between them.  
First:

```
vTransform = vtk.vtkTransform()
vTransform.Translate(-0.88, 35.4, 5.65) # translate by -isocenter
vTransform.RotateZ(10) # The angle is in degrees
vTransform.Translate(0.88, -35.4, -5.65)
imageNode.ApplyTransform(vTransform)

```

Second:

```
transform = slicer.vtkMRMLLinearTransformNode()
scene = slicer.mrmlScene
scene.AddNode(transform) 
imageNode.SetAndObserveTransformNodeID(transform.GetID())
vTransform = vtk.vtkTransform()
vTransform.Translate(-0.88, 35.4, 5.65) # translate by -isocenter
vTransform.RotateZ(10) # The angle is in degrees
vTransform.Translate(0.88, -35.4, -5.65)
transform.SetAndObserveMatrixTransformToParent(vTransform.GetMatrix())
#transform.SetMatrixTransformToParent(vTransform.GetMatrix())
```

---

<div class="post-metadata">

**Author:** ![lassoan](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lassoan/32/13_2.png) [@lassoan](https://discourse.slicer.org/u/lassoan)\
**Post date:** [January 31, 2019, 12:27am UTC](https://discourse.slicer.org/t/the-problem-between-node-and-vtkprop3d/5526/6 "2019-01-31T00:27:52Z")

</div>

First example changes the image position/orientation permanently.

Second example applies a transform to the image. You can remove the transform to get back the image to its original pose or harden the transform to change the image pose permanently.

Simplified and more up-to-date version of the second example:

```auto
transform = slicer.mrmlScene.AddNewNodeByClass('vtkMRMLLinearTransformNode')
imageNode.SetAndObserveTransformNodeID(transform.GetID())
vTransform = vtk.vtkTransform()
vTransform.Translate(-0.88, 35.4, 5.65) # translate by -isocenter
vTransform.RotateZ(10) # The angle is in degrees
vTransform.Translate(0.88, -35.4, -5.65)
transform.SetMatrixTransformToParent(vTransform.GetMatrix())

```
