You can add a rotation argument to primitive_cube_Add
. Note that python rotation options use radians, so you may need to use math.radians(x)
bpy.ops.mesh.primitive_cube_add(radius=1, location=(x,y,z), rotation=(rx,ry,rz))
You can also directly change the rotatation of the object after you have created it. After primitive_cube_add()
the new object is selected and is the active object.
bpy.context.active_object.rotation_mode = 'XYZ'
bpy.context.active_object.rotation_euler = (rx, ry, rz)
While the above example works it is more correct to specify the rotation using a mathutils.Euler
or mathutils.Quaternion
object.