# Set Orientation at vtkCylinderSource

**URL:** <https://discourse.slicer.org/t/set-orientation-at-vtkcylindersource/8663>\
**Category:** Development\
**Tags:** python\
**Created:** [October 3, 2019, 6:25pm UTC](https://discourse.slicer.org/t/set-orientation-at-vtkcylindersource/8663 "2019-10-03T18:25:32Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![siaeleni](https://avatars.discourse-cdn.com/v4/letter/s/b4bc9f/32.png) [@siaeleni](https://discourse.slicer.org/u/siaeleni)\
**Post date:** [October 3, 2019, 6:25pm UTC](https://discourse.slicer.org/t/set-orientation-at-vtkcylindersource/8663/1 "2019-10-03T18:25:32Z")

</div>

Hello,

I would like to Set Orientation/Direction to a vtkCylinderSource that I create in Slicer in python.  
From vtk documentation I realized that I have to set the orientation through vtkActor, but how can I display it on Slicer?

Here is a piece of code:

> cyl = vtk.vtkCylinderSource()  
> cyl.SetRadius(50)  
> cyl.SetResolution(50)  
> cyl.SetHeight(100)
> 
> mapper = vtk.vtkPolyDataMapper()  
> mapper.SetInputConnection(cyl.GetOutputPort())
> 
> actor = vtk.vtkActor()  
> actor.SetOrientation(0,0,90)  
> actor.SetMapper(mapper)
> 
> node = cyl.GetOutput()  
> n = slicer.mrmlScene.AddNewNodeByClass(‘vtkMRMLModelNode’, ‘Cylinder’)  
> n.SetAndObservePolyData(node)  
> n.CreateDefaultDisplayNodes()  
> n.SetDisplayVisibility(True)  
> cyl.Update()

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:** [October 3, 2019, 6:38pm UTC](https://discourse.slicer.org/t/set-orientation-at-vtkcylindersource/8663/2 "2019-10-03T18:38:22Z")

</div>

If you need to dynamically set its position/rotation then you set a parent transform to it. If you need a fixed pose then to cylinder source output you can apply a vtkTransformPolyDataFilter on set the output of that into the model node.

---

<div class="post-metadata">

**Author:** ![siaeleni](https://avatars.discourse-cdn.com/v4/letter/s/b4bc9f/32.png) [@siaeleni](https://discourse.slicer.org/u/siaeleni)\
**Post date:** [October 3, 2019, 7:18pm UTC](https://discourse.slicer.org/t/set-orientation-at-vtkcylindersource/8663/3 "2019-10-03T19:18:45Z")

</div>

yes, I was wondering whether there is another option for dynamically setting the transformation except from SetMatrixTransformToParent. 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:** [October 3, 2019, 7:25pm UTC](https://discourse.slicer.org/t/set-orientation-at-vtkcylindersource/8663/4 "2019-10-03T19:25:28Z")

</div>

In your module you can keep a reference to vtkTransformPolyDataFilter and update it whenever you need. However, in general it is more useful if you don’t keep transforms private but store in MRML nodes so that other nodes and modules can use it. For example, if you just store a transform privately then you cannot easily modify or inspect current values using GUI, use it to reslice a volume, combine with other transforms, save/load with the scene, etc.
