in my blender file, I have created two vehicles objects which named as 'AudiA2' and 'JeepCherokee'
now I have created a simple program to show them on the scene with different positions created from the program.
def choose_car_position_byname(name, pos):
bpy.data.objects[name].hide_render = False;
print("location ", bpy.data.objects[name].location )
bpy.data.objects[name].location = bpy.data.objects[name].location + mathutils.Vector((pos,1,0))
print("location ", bpy.data.objects[name].location )
return bpy.data.objects[name]
car1 = choose_car_position_byname('AudiA2',1)
car2 = choose_car_position_byname('JeepCherokee',0)
However from the program executed, I can only see one car on the scene, which is the car2. as shown below
Ultimately I found out the second car will block the first car, because if I added the following code, two car will show up
bpy.data.objects["AudiA2"].rotation_euler.z = 270 / 180 * math.pi
as shown in here
Now the question is why I can't set the location of the obj. I have tried many ways, but none of them is not working, it is totally puzzling me. My environment is OSX 10.10.1, blender 2.76.
# first approach
bpy.data.objects["AudiA2"].location.x += 3.0
bpy.data.objects["AudiA2"].location.y += 2.0
bpy.data.objects["AudiA2"].location.z += 0.0
# second approach
vec = mathutils.Vector((3.0, 2.0, 1.0))
inv = bpy.data.objects['AudiA2'].matrix_world.copy()
inv.invert()
vec_rot = vec * inv
bpy.data.objects['AudiA2'].location = bpy.data.objects['AudiA2'].location + vec_rot
# third approach
bpy.data.objects["AudiA2"].location = (20, 20, 10)
# fourth approach
bpy.data.objects["AudiA2"].location[0] = 3
bpy.data.objects["AudiA2"].location[0] = bpy.data.objects["AudiA2"].location[0] + 3
#fifth approach
bpy.data.objects['AudiA2'].location = bpy.data.objects['AudiA2'].location + mathutils.Vector((3,2,0))
The code and blender files are all uploaded to dropbox. https://www.dropbox.com/s/fxar4owxvkxrxi7/scene2.blend?dl=0 https://www.dropbox.com/s/xvsg879k2bil2pn/batch3.py?dl=0
to work with the code, you have to pip install pypng, which could be used to output the png image.To run the application, the command is similar to this-
./blender_application_path -b blend_path -P python_path
for example
./Applications/Blender/blender.app/Contents/MacOS/blender -b scene2.blend -P batch3.py





.../python2.7/site-packages/tosys.path? – sambler Oct 03 '15 at 08:49