I am working with blender from batch (blender -b untitled.blend -P scripts.py) to generate renders.
But in my script I call the function project_from_view, and I have the error “Operator bpy.ops.uv.project_from_view.poll() failed, context is incorrect”
Everything is ok when I do it myself, but when I try to run it from a script it fails. Anyone knows how to solve this? (Changing context maybe?)
I don’t have any experience with that operator, but when you get the poll error then something is out of context as it says. The blender API only lets certain data be changed from certain context. This is done on purpose so as not to cause conflicts and memory errors etc. My guess would be that you are trying to call the operator from the wrong part of the code (…and the poll() function is stopping you).
I have a feeling the UI is not loaded when you run in bg mode.
Typically operators check for the active area type, a selection or active object they can operate on, but some operators are more picky about when they run.
Check what you get for context.area… is it None?