Community
Maya Forum
Welcome to Autodesk’s Maya Forums. Share your knowledge, ask questions, and explore popular Maya topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Convert Maya World Coordinates to Screen Coordinates

0 REPLIES 0
Reply
Message 1 of 1
krs8ZE3QE
259 Views, 0 Replies

Convert Maya World Coordinates to Screen Coordinates

Hello!
Maya 2023 question. I have placed locators on my object and would like to convert maya world coordinates to screen coordinates with python script.
I tried to use the following code but can't figure out what I should pass to view.worldToView().
```
import maya.cmds as cmds
import maya.OpenMaya as OpenMaya
import maya.OpenMayaUI as OpenMayaUI

camera = 'top'
locator='LeftEye'

locator_pos = cmds.xform(locator, query=True, worldSpace=True, translation=True)

view = OpenMayaUI.M3dView.active3dView()
projection = OpenMaya.MPoint()
pos = OpenMaya.MPoint(locator_pos[0], locator_pos[1], locator_pos[2])
xPos, yPos, visible = view.worldToView(pos)
```
As a result I get an error:
TypeError: M3dView_worldToView expected 4 arguments, got 2
As far as I can see in the documentation (https://help.autodesk.com/view/MAYAUL/2022/ENU/?guid=Maya_SDK_py_ref_class_open_maya_u_i_1_1_m3d_vie...) I have to pass in an MPoint object, which I do.
I would be very grateful for any help.

0 REPLIES 0

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report