I have noticed several behaviours in Blender that are different depending on whether the full UI is used, or if Blender is being automated 'headless' using a script on the command line.
By 'headless', I refer to using a command such as:
$ ./blender -b <file.blend> -P <script.py>
My test directory starts with these files:
-rw-r--r-- 1 doug doug 67 2010-10-20 18:50 save_as_new.py -rw-r--r-- 1 doug doug 397124 2010-10-20 18:45 cube_offorigin_start.blend
cube_offorigin_start.blend is a scene that contains a single Cube object that is located away from the world origin.
First of all, when compiling a test script for this bug report another bug surfaced, so I'll report that first.
save_as_new.py currently contains this code:
import bpy bpy.ops.wm.save_as_mainfile( filepath='TEST1.blend' )
1. bpy.ops.wm.save_as_mainfile() created a junk file in the cwd $ ../blender/blender -b cube_offorigin_start.blend -P save_as_new.py found bundled python: /home/doug/Development/blender/install/linux2/2.54/python read blend: /home/doug/blender_debug/cube_offorigin_start.blend *bpy stats* - tot exec: 6, tot run: 0.0016sec, average run: 0.000259sec, tot usage 3.0023%
Blender quit $ ls -l -rw-r--r-- 1 doug doug 67 2010-10-20 18:50 save_as_new.py -rw-r--r-- 1 doug doug 397124 2010-10-20 18:45 cube_offorigin_start.blend -rw-r--r-- 1 doug doug 12 2010-10-20 18:56 ~ș?d? -rw-r--r-- 1 doug doug 311648 2010-10-20 18:56 TEST1.blend $ cat \~ș�d^? TEST1.blend $
Most odd.
My original bug report was about the object align operator:
2. use_align_operator.py: import bpy
for obj in bpy.data.objects: obj.select = False bpy.data.objects['Cube'].select = True
bpy.ops.object.align( align_mode = 'OPT_1', # Negative relative_to = 'OPT_1', # World origin align_x = True, align_y = True, align_z = True )
bpy.ops.wm.save_as_mainfile( filepath='cube_align_operator.blend' )
$ ../blender/blender -b cube_offorigin_start.blend -P use_align_operator.py found bundled python: /home/doug/Development/blender/install/linux2/2.54/python read blend: /home/doug/blender_debug/cube_offorigin_start.blend Traceback (most recent call last): File "/home/doug/Development/blender/install/linux2/2.54/scripts/op/object_align.py", line 271, in execute align_objects(self.align_x, self.align_y, self.align_z, self.align_mode, self.relative_to) File "/home/doug/Development/blender/install/linux2/2.54/scripts/op/object_align.py", line 34, in align_objects for obj in bpy.context.selected_objects: AttributeError: 'Context' object has no attribute 'selected_objects' *bpy stats* - tot exec: 6, tot run: 0.0022sec, average run: 0.000366sec, tot usage 4.2089% Error Totblock: 9 wmOperatorReportList len: 40 0x290c0b8 OBJECT_OT_align len: 168 0x2a081a8 wmOperatorPtrRNA len: 24 0x2f72478 IDProperty array dup len: 96 0x2a08298 IDProperty array dup len: 96 0x2a08348 IDProperty array dup len: 96 0x2a083f8 IDProperty array dup len: 96 0x2a084a8 IDProperty array dup len: 96 0x2a08558 IDProperty array dup len: 96 0x2a08608
Blender quit $ ls -l -rw-r--r-- 1 doug doug 311648 2010-10-20 19:02 cube_align_operator.blend -rw-r--r-- 1 doug doug 397124 2010-10-20 18:45 cube_offorigin_start.blend -rw-r--r-- 1 doug doug 67 2010-10-20 19:00 save_as_new.py -rw-r--r-- 1 doug doug 12 2010-10-20 18:56 ~ș?d? -rw-r--r-- 1 doug doug 311648 2010-10-20 18:56 TEST1.blend -rw-r--r-- 1 doug doug 26 2010-10-20 19:02 tor.blen ?3?b? -rw-r--r-- 1 doug doug 315 2010-10-20 19:01 use_align_operator.py
The Cube in cube_align_operator.blend is not aligned as expected - it has not moved at all.
I have been writing another script in which setting an object's location like this: MY_OBJ.location = [0,0,0] hasn't worked either, but I'm currently unable to reproduce that in a debug environment outside of that script.
I've attached a tar.gz containing all the files I used and created in this report. |