# How can I get markup's 2D position in 3D view

**URL:** <https://discourse.slicer.org/t/how-can-i-get-markups-2d-position-in-3d-view/29521>\
**Category:** Support\
**Created:** [May 18, 2023, 1:26am UTC](https://discourse.slicer.org/t/how-can-i-get-markups-2d-position-in-3d-view/29521 "2023-05-18T01:26:49Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![nnzzll](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/nnzzll/32/16350_2.png) [@nnzzll](https://discourse.slicer.org/u/nnzzll)\
**Post date:** [May 18, 2023, 1:26am UTC](https://discourse.slicer.org/t/how-can-i-get-markups-2d-position-in-3d-view/29521/1 "2023-05-18T01:26:49Z")

</div>

Is there a way to calculate the markup’s position in the 3D view? I mean the 2D position when capturing the 3D view into a 2D image, not the RAS coordinates.

---

<div class="post-metadata">

**Author:** ![nnzzll](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/nnzzll/32/16350_2.png) [@nnzzll](https://discourse.slicer.org/u/nnzzll)\
**Post date:** [May 18, 2023, 4:00am UTC](https://discourse.slicer.org/t/how-can-i-get-markups-2d-position-in-3d-view/29521/2 "2023-05-18T04:00:20Z")

</div>

For anyone who has the same question, I just figure it out.

First, get the `renderer` from the 3D view:

```auto
threeDWidget = slicer.app.layoutManager().threeDWidget(0)
threeDView = threeDWidget.threeDView()
renderWindow = threeDView.renderWindow()
renderer = renderWindow.GetRenderers().GetFirstRenderer() 

```

Then, set the markup’s homogeneous RAS position to renderer

```auto
worldPosition = [*markupNode.GetNthControlPointPosition(0), 1]
renderer.SetWorldPoint(worldPosition)
renderer.WorldToDisplay()
imagePosition = renderer.GetDisplayPoint()

```

Note that the projection is upsided-down, so we need another step to set up the right coordinates:

```auto
imagePosition[1] = threeDView.size.height() - imagePosition[1]

```
