The OpenMayaUI API's M3dView class has several methods for doing this. An example of projecting a 3d worldspace point to 2d screen-space can be found here:
Here's an overview of the pertinent methods:
Here's an overview of the pertinent methods:
viewToWorld: Takes a point in port coordinates and returns a corresponding ray in world coordinates. Takes a point in port coordinates and returns a point on the near and far clipping planes.viewToObjectSpace: Takes a point in port coordinates and returns a corresponding ray in object coordinates.worldToView: Converts a point in world space to port space.projectionMatrix: Returns the projection matrix currently being used by OpenGL in the current view.modelViewMatrix: Returns the modelview matrix currently being used by OpenGL in the current view.