# How to Align a vtk Cylinder to a Known Vector

**URL:** https://discourse.slicer.org/t/how-to-align-a-vtk-cylinder-to-a-known-vector/35880
**Category:** Development
**Tags:** python
**Created:** [May 2, 2024, 6:31pm UTC](https://discourse.slicer.org/t/how-to-align-a-vtk-cylinder-to-a-known-vector/35880 "2024-05-02T18:31:39Z")
**Posts on this page:** 1
**Showing post:** 2

<div class="post-metadata">

### Author: ![rfenioux](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/rfenioux/32/70007_2.png) [@rfenioux](https://discourse.slicer.org/u/rfenioux)
#### Post date: [May 3, 2024, 7:57am UTC](https://discourse.slicer.org/t/how-to-align-a-vtk-cylinder-to-a-known-vector/35880/2 "2024-05-03T07:57:22Z")

</div>

I think the simplest way to achieve that would be the following:

- retrieve the existing control points as numpy arrays
- using those, compute the two endpoints of your desired line
- create a markupsLineNode with these new points as control points
- hide the label text and the new control points to only show the line

To do all that, I recommend looking at the examples in the [script repository](https://slicer.readthedocs.io/en/latest/developer_guide/script_repository.html) and/or search for previous answers in the discourse.

---

_[View the full topic](https://discourse.slicer.org/t/how-to-align-a-vtk-cylinder-to-a-known-vector/35880)._
