How to run a geomtry nodes tool while in the uv editor?

Hi, Is there any way to execute a geomtry nodes tool while in the uv editor? Currently it only works while the mouse is over in the 3d view. Like this:

bpy.ops.geometry.execute_node_group(name="Unwrap In Place", session_uid=8431)

But I whant to be able to execute it when pressing a button while in the uv editor as well, currently nothing happense, and I have verfied that there is nothing wrong with the tool since it works if the button is placed in the 3d viewport n panel.

1 Like

If it works when the mouse is in the 3D viewport, then you’re probably running into a context issue.

The operator expects the 3D View context, but it gets the UV Editor context instead, and doesn’t run.
You can override the context of the operator to force it to run from the area you want by grabbing the right area from elsewhere onscreen:

areas = bpy.context.screen.areas
area = [a for a in areas if a.type == 'VIEW_3D'][0]

with bpy.context.temp_override(area=area):
    bpy.ops.geometry.execute_node_group(name="Unwrap In Place", session_uid=8431)
2 Likes

Hey @SpectralVectors Thank you so mutch! :heart: It worked great!

1 Like