Moving Cursor to Object Location with Python

I am trying to find a way move the cursor to the selected object origin point in screen space. I have found bpy.context.window.cursor_warp(x,y) but I am not sure how to get the x, y screen space location of a 3D object. Obviously the convert_to_screen_space_location() function doesn’t exist, but this is essentially what I am trying to do. Anyone have any ideas?

import bpy
obj = bpy.context.object
x,y = convert_to_screen_space_location(obj.location)

There are some utilities in bpy_extras for that. The one you’re after is called location_3d_to_region_2d.

Example (needs to run in viewport for region_data):

from bpy_extras.view3d_utils import location_3d_to_region_2d
from mathutils import Vector

region = context.region
co = location_3d_to_region_2d(
region_offset = Vector((region.x, region.y))
context.window.cursor_warp(*(co + region_offset))

You can also get region_data if you know the viewport area.

rv3d =

Thank you so much! That is exactly what I was looking for. Those view3d_utils will help me out a lot.