Project UV from view with bounds - possible through script?

Hi everyone,

I’m writing a script for a research student regarding computer vision, he wants to use blender to create controlled tests that he can feed his computer vision algorithm.

One of the things he needs is a rendered image with a normal map of the object mapped on it as a color texture.

I already automated creating a normal map via baking on a plane, but in order to display the map as a texture from the angle of the camera, I need to UV map the object via project from view (bounds) option.

Problem is, the “project from view” operators belong to bpy.ops.uv.

bpy.ops.uv.project_from_view(scale_to_bounds=True)

When I run it from the console, I get an error saying that the context is incorrect.

RuntimeError: Operator bpy.ops.uv.project_from_view.poll() failed, context is incorrect

The poll probably only allow this operator to work in the 3D view.

I can’t run this script from a panel (the user requires the whole script to run from the shell), so I can’t get the correct context.

Is there some other way to project from a specific view or angle or another version of this operator?

Hi,

It has been a long time, but have you found a solution by any chance ?

Thanks !