[Bf-python] bpy.ops.mesh.primitive_*_add() not working in scripts executed from the command line (blender -P <script>)...

Dietrich Bollmann diresu at web.de
Fri Oct 30 05:10:36 CET 2009


Hi,

The following most simple of all scripts doesn't work when executed from
the command line :)

---

cat > /tmp/cube.py <<FIN
import bpy
bpy.ops.mesh.primitive_cube_add()
FIN

blender -P /tmp/cube.py

found bundled
python: /home/dietrich/blender/install/linux2/.blender/python
Traceback (most recent call last):
  File "/tmp/cube.py", line 2, in <module>
    bpy.ops.mesh.primitive_cube_add()
  File
"/home/dietrich/blender/install/linux2/.blender/scripts/modules/bpy_ops.py", line 145, in __call__
    return op_call(self.idname(), C_dict, kw)
SystemError: bpy.__ops__.call: operator poll() function failed, context
is incorrect
*bpy stats* - tot exec: 78,  tot run: 0.0083sec,  average run:
0.000106sec,  tot usage 0.2962%

---

The same command works when executed from inside the Blender GUI
(blender "Console" window).

The 'context' seems to depend on the mouse being somewhere positioned on
in the blender GUI.  This is of course not the case when executing the
script from an xterm with the 'blender -P <script>' command.

Am I missing something?

Finally I would be happy to thank everybody involved in the development
of Blender 2.5!  I am very impressed by the new interface and
functionality!

Cheers, Dietrich


PS: By the way, I tried to read the sources (pyop_call(),
WM_operator_poll(), ...) before writing this email but had the
impression, that I have to read all of them to understand just some
part :) Is there some documentation online which could help?

Thanks again...








More information about the Bf-python mailing list