I want to read a ply mesh at blender startup using a python script given in the command line:
blender --python load_ply.py.
My script load_ply.py basically looks like this:
import bpy
This line is the issue:
bpy.ops.wm.read_factory_settings(use_empty=True)
bpy.ops.import_mesh.ply(filepath='mesh.ply')
It works fine until I use bpy.ops.wm.read_factory_settings(use_empty=True) to clear the scene before the import, which gives the following error:
Python: Traceback (most recent call last):
File "/path/to/blender/blender-2.92.0-linux64/2.92/scripts/addons/io_mesh_ply/__init__.py", line 87, in execute
context.window.cursor_set('WAIT')
AttributeError: 'NoneType' object has no attribute 'cursor_set'
location: /path/to/blender/blender-2.92.0-linux64/2.92/scripts/modules/bpy/ops.py:132
Error: Python: Traceback (most recent call last):
File "/path/to/blender/blender-2.92.0-linux64/2.92/scripts/addons/io_mesh_ply/init.py", line 87, in execute
context.window.cursor_set('WAIT')
AttributeError: 'NoneType' object has no attribute 'cursor_set'
location: /path/to/blender/blender-2.92.0-linux64/2.92/scripts/modules/bpy/ops.py:132
Traceback (most recent call last):
File "/path/to/my/script/load_ply.py", line 5, in <module>
bpy.ops.import_mesh.ply(filepath='mesh.ply')
File "/path/to/blender/blender-2.92.0-linux64/2.92/scripts/modules/bpy/ops.py", line 132, in call
ret = _op_call(self.idname_py(), None, kw)
RuntimeError: Error: Python: Traceback (most recent call last):
File "/path/to/blender/blender-2.92.0-linux64/2.92/scripts/addons/io_mesh_ply/init.py", line 87, in execute
context.window.cursor_set('WAIT')
AttributeError: 'NoneType' object has no attribute 'cursor_set'
location: /path/to/blender/blender-2.92.0-linux64/2.92/scripts/modules/bpy/ops.py:132
What is the meaning of this error?
What change does the read_factory_settings operator bring?
I use blender 2.92.0 on Debian 10.
A basic file mesh.ply:
ply
format ascii 1.0
element vertex 8
property float32 x
property float32 y
property float32 z
element face 6
property list uint8 int32 vertex_index
end_header
0 0 0
0 0 1
0 1 1
0 1 0
1 0 0
1 0 1
1 1 1
1 1 0
4 0 1 2 3
4 7 6 5 4
4 0 4 5 1
4 1 5 6 2
4 2 6 7 3
4 3 7 4 0
--factory-startupon the command line instead. – scurest Apr 11 '21 at 21:46