# Can I center the views on a crosshair position?

**URL:** <https://discourse.slicer.org/t/can-i-center-the-views-on-a-crosshair-position/36244>\
**Category:** Development\
**Created:** [May 18, 2024, 3:03am UTC](https://discourse.slicer.org/t/can-i-center-the-views-on-a-crosshair-position/36244 "2024-05-18T03:03:55Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![sullivak](https://avatars.discourse-cdn.com/v4/letter/s/8797f3/32.png) [@sullivak](https://discourse.slicer.org/u/sullivak)\
**Post date:** [May 18, 2024, 3:03am UTC](https://discourse.slicer.org/t/can-i-center-the-views-on-a-crosshair-position/36244/1 "2024-05-18T03:03:55Z")

</div>

Hi. I can set the location of crosshairs, e.g.  
slicer.mrmlScene.GetNodesByClass(‘vtkMRMLCrosshairNode’).GetItemAsObject(0).SetCrosshairRAS(point)

but is there a way to re-center the views on that location?

---

<div class="post-metadata">

**Author:** ![cpinter](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/cpinter/32/7995_2.png) [@cpinter](https://discourse.slicer.org/u/cpinter)\
**Post date:** [May 20, 2024, 12:20pm UTC](https://discourse.slicer.org/t/can-i-center-the-views-on-a-crosshair-position/36244/2 "2024-05-20T12:20:37Z")

</div>

You can use this API:

> <https://github.com/Slicer/Slicer/blob/main/Libs/MRML/Core/vtkMRMLSliceNode.h#L373-L387>

---

<div class="post-metadata">

**Author:** ![sullivak](https://avatars.discourse-cdn.com/v4/letter/s/8797f3/32.png) [@sullivak](https://discourse.slicer.org/u/sullivak)\
**Post date:** [May 20, 2024, 9:23pm UTC](https://discourse.slicer.org/t/can-i-center-the-views-on-a-crosshair-position/36244/3 "2024-05-20T21:23:39Z")

</div>

Thanks, that did the trick!

Not sure if this is the exact right way, but it worked:

```auto
def set_ras_coords(point: list[float]):
    slicer.mrmlScene.GetNodesByClass('vtkMRMLCrosshairNode').GetItemAsObject(0).SetCrosshairRAS(point)
    sliceNodes = list(slicer.mrmlScene.GetNodesByClass('vtkMRMLSliceNode'))
    for sliceNode in sliceNodes:
        sliceNode.JumpAllSlices(point[0], point[1], point[2])

```
