This code works. But how to animate, zoom, scale, render?

blender -P help5.txt

This python 3.4.2 script works with blender 2.72b

to create objects, UNION them together, insert armatures.

How can the armatures stay with thier objects?

How can the armatures move?

How can view zoom out?

How can everything scale down?

how to render?

import bpy

clean up. remove camera, lamp, cube.

bpy.ops.object.select_by_type(type=‘CAMERA’)
bpy.ops.object.move_to_layer(layers=(False, False, False, False, False, False, False, False, False, True, False, False, False, False, False, False, False, False, False, False))
bpy.ops.object.select_by_type(type=‘LAMP’)
bpy.ops.object.move_to_layer(layers=(False, False, False, False, False, False, False, False, False, True, False, False, False, False, False, False, False, False, False, False))
bpy.ops.object.select_by_type(type=‘MESH’)
bpy.ops.object.delete()

set initial values.

rotate_x=0; rotate_y=0; rotate_z=0;
resize_x=1; resize_y=1; resize_z=1;
location_x=0; location_y=0; location_z=0;

def reset6():
rotate_x=0; rotate_y=0; rotate_z=0;
resize_x=1; resize_y=1; resize_z=1;
location_x=0; location_y=0; location_z=0;

def transform5(rotate_x, rotate_y, rotate_z, resize_x, resize_y, resize_z, location_x, location_y, location_z):
bpy.ops.transform.rotate(value=(11),axis=(rotate_x, rotate_y, rotate_z))
bpy.ops.transform.resize(value=(resize_x, resize_y, resize_z))
name2.location = (location_x, location_y, location_z)

def union1(Body, name2):
mod_bool = Body.modifiers.new(‘my_bool_mod’, ‘BOOLEAN’)
mod_bool.operation = ‘UNION’
mod_bool.object = name2
bpy.context.scene.objects.active = Body
Body = bpy.ops.object.modifier_apply(modifier = ‘my_bool_mod’)
name2.select = True
bpy.ops.object.delete()
Body = bpy.context.object
Body.name = ‘Body’

def difference2(Body, name2):
mod_bool = Body.modifiers.new(‘my_bool_mod’, ‘BOOLEAN’)
mod_bool.operation = ‘DIFFERENCE’
mod_bool.object = name2
bpy.context.scene.objects.active = Body
Body = bpy.ops.object.modifier_apply(modifier = ‘my_bool_mod’)
name2.select = True
bpy.ops.object.delete()
Body = bpy.context.object
Body.name = ‘Body’

def scene4():
rig = bpy.data.objects.new(‘MyRig’, amt)
scn = bpy.context.scene
scn.objects.link(rig)
scn.objects.active = rig

def bone7(head_x, head_y, head_z, tail_x, tail_y, tail_z):
bone.head = (head_x, head_y, head_z)
bone.tail = (tail_x, tail_y, tail_z)

Create a simple cylinder. Body.

bpy.ops.mesh.primitive_cylinder_add()

Get the cylinder object and rename it. Body.

Body = bpy.context.object
Body.name = ‘Body’

Create a simple cylinder. Trunk.

bpy.ops.mesh.primitive_cylinder_add()
reset6()

Resize the cylinder. Trunk. horizontal(“x: 135”) deep(“y: 135”) vertical(“z: 250”)

resize_x=135; resize_y=135; resize_z=250;
name2 = bpy.context.object; name2.name = ‘Trunk’;
transform5(rotate_x, rotate_y, rotate_z, resize_x, resize_y, resize_z, location_x, location_y, location_z)
union1(Body, name2)

Create a simple cylinder. Up Arm Left.

bpy.ops.mesh.primitive_cylinder_add()
rotate_x=0; rotate_y=1; rotate_z=0;
resize_x=90; resize_y=30; resize_z=30;
location_x=225; location_y=0; location_z=220;
name2 = bpy.context.object; name2.name = ‘Up_Arm_Left’;
transform5(rotate_x, rotate_y, rotate_z, resize_x, resize_y, resize_z, location_x, location_y, location_z)
union1(Body, name2)
amt = bpy.data.armatures.new(‘MyRigData’)
scene4()

Create bones +x, 0y, +z

bpy.ops.object.mode_set(mode=‘EDIT’)
bone = amt.edit_bones.new(‘Up_Arm.L’)
head_x=135; head_y=0; head_z=220;
tail_x=315; tail_y=0; tail_z=220;
bone7(head_x, head_y, head_z, tail_x, tail_y, tail_z)

Create a simple cylinder. Lo Arm Left.

bpy.ops.mesh.primitive_cylinder_add()
rotate_x=0; rotate_y=1; rotate_z=0;
resize_x=90; resize_y=20; resize_z=20;
location_x=405; location_y=0; location_z=220;
name2 = bpy.context.object; name2.name = ‘Lo_Arm_Left’;
transform5(rotate_x, rotate_y, rotate_z, resize_x, resize_y, resize_z, location_x, location_y, location_z)
union1(Body, name2)
amt = bpy.data.armatures.new(‘MyRigData’)
scene4()
bpy.ops.object.mode_set(mode=‘EDIT’)
bone = amt.edit_bones.new(‘Lo_Arm.L’)
head_x=315; head_y=0; head_z=220;
tail_x=405; tail_y=0; tail_z=220;
bone7(head_x, head_y, head_z, tail_x, tail_y, tail_z)

Create a material.

mat = bpy.data.materials.new(name = ‘my_material’)

Set some properties of the material.

mat.diffuse_color = (0.716, 0.352, 0.178)
mat.diffuse_shader = ‘LAMBERT’
mat.diffuse_intensity = 1.0
mat.specular_color = (1., 1., 1.)
mat.specular_shader = ‘COOKTORR’
mat.specular_intensity = 0.05
mat.alpha = 1
mat.ambient = 0.5

Assign the material to the cylinder.

mesh = Body.data
mesh.materials.append(mat)

add plane. horizontal(“x: 0”) deep(“y: 0”) vertical(“z: 860”)

bpy.ops.mesh.primitive_plane_add(radius=1, view_align=False, enter_editmode=False, location=(0, 0, -860), layers=(True, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False))

resize plane. horizontal(“x: 150”) deep(“y: 150”) vertical(“z: 0”)

bpy.ops.transform.resize(value=(150, 150, 0), constraint_axis=(False, False, False), constraint_orientation=‘GLOBAL’, mirror=False, proportional=‘DISABLED’, proportional_edit_falloff=‘SMOOTH’, proportional_size=1)

(De)select all. “object interaction mode” must be in “edit mode”.

bpy.ops.object.mode_set(mode=‘EDIT’)
bpy.ops.mesh.select_all(action=‘DESELECT’)

More words, less code dump, I’m not going to parse out 141 lines of code to figure out what your problem is.

What are you trying to do and what issues are you having?

I have python 3.4.2 script that works with blender 2.72b to create objects, UNION them together, insert armatures.

I am looking for more script that does this.
make armatures stay with thier objects.
make armatures move.
view zoom out.
everything scale down.
render.

can you post your script to pasteall.org? The forum destroys all indentation.

http://www.pasteall.org/73878. The script has no indentation, but still works. I sent more code than above.

Wow, that’s an interesting way to make a mesh. Why are you doing all of this algorithmically?

Because I like it that way. It is my personal preference. It can be exactly reproduced and changed to exact specifications. It is the only way I know how.

The code works, I am asking for more code to put into it.

That’s awesome, more power to you! Unfortunately, most of the armature and animation operators are highly context dependent, and I am not an expert in context management. I think it should be possible, but it will take some definite debugging. Good luck!