How to use python script to move and rotate an object in blender?

Hi everyone,
I just start to learn blender. I have added pipe joint python script into blender:
http://wiki.blender.org/index.php/Extensions:2.5/Py/Scripts/Add_Mesh/Add_Pipe_Joints

I can create a pipe joint, say elbow joint, with the script:

elbow_joint = bpy.ops.mesh.primitive_elbow_joint_add
elbow_joint(radius=1,div=32,angle=0.78988,startLength=3,endLenth=3)

I want to use python script to rotate the “elbow_joint” and move it to a new location. So I can create a pipe system.

Can anybody drop several lines of python script here? So I can start the coding from there.

Thanks a lot in advance.

Ouyang

The code is different depending upon what version of Blender you are using.

Do a search in the python forum and you will find your couple of lines of code.

Finally, I found a way to do it. I am not sure it is a good way or not but it works so far.
The demo script is as follows.

from bpy import context
from math import sin, cos, radians
cursor = context.scene.cursor_location
radius = 10
anglesInRadians = [radians(degree) for degree in range(0,360,36)]

for theta in anglesInRadians:
#add_elbow_joint()
bpy.ops.mesh.primitive_elbow_joint_add()
x = cursor.x + radiuscos(theta)
y = cursor.y + radius
cos(theta)
z = cursor.z
context.active_object.location.xyz = [x,y,z]
context.active_object.rotation_euler = [theta,0,0]

ouyang

I could be completely mistaken, but don’t you mean

y = cursor.y + radius*sin(theta)

?

can you clarify what your doing here !

the pipe joint command in first post

are theses added to the pipe joint script or in another script

and do you have to start the pipe script joint first or not ?

Thanks