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

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.

1 Like

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

First, get the renderer from the 3D view:

threeDWidget =
threeDView = threeDWidget.threeDView()
renderWindow = threeDView.renderWindow()
renderer = renderWindow.GetRenderers().GetFirstRenderer() 

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

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

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

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