How does GetCursorPos() really work?

Hi All!
I am new here on the Rhino forum, however I am not new Rhino user.
Recently I started to play with Python scripting and now I wonder how does the GetCursorPos() function work, more precisely: in what way are 2D screen coordinates translated to world/3D coordinates?

I’ve created a script that puts a line between camera position and cursor position:

import rhinoscriptsyntax as rs
def main():
    something=rs.GetPoint("indicate point")
    if not cursordata: return
if __name__ =="__main__":

The effect is visible below:

Here I “shooted” lines towards the same object (camera target was set at it), with the same zoom, but at different angles. And lengths of the lines are completely different!
Can anybody answer how is depth of the cursor position calculated in the GetCursorPos() function?


Hey Andrzej,

So I was doing some testing and it looks like GetCursorPos returns the position in the world at the nearest clipping plane.

Before running your script:


You can see the line stops where the near clipping plane used to be, and zooming in to the camera location, the near clipping plane has moved:

And re-running your script validates this:

So when you were rotating around the object, the camera’s clipping planes were changing and thus the seemingly random lines.

This is definitely odd behaviour because I was also wondering what world coordinates the GetCursorPos returns, since it definitely wasn’t the coordinates in the bottom left (on the status bar when set to world).