A question about rotation_euler and rotation_quaternion

I create a cube object with python script:

import bpy
add_cube = bpy.ops.mesh.primitive_cube_add
layers = [False]*32
layers[0] = True
add_cube(location=(0,0,0), layer=layers)

Now I can rotate it with “rotation_euler”:

bpy.context.active_object.rotation_euler=[1,1,1]

But with “rotation_quaternion” , the following script can not rotate the object at all

bpy.context.active_object.rotation_quaternion=[1,0,0,0]

Did I miss something?

Any suggestions?

ouyang

I don’t fully understand how Quaternions work yet, but if you try a different value like:

bpy.context.active_object.rotation_quaternion=[1, 0.5, 0, 0]
It should display a rotation.

I have tried the value [1, 0.5, 0, 0] and many others for rotation_quaternion. It does not display any rotation.

The rotation representations are currently mutually exclusive, with the rotation representation being used being specified by the rotation_mode setting.

Thanks a lot, Aligorith. It works now.

import bpy
add_cube = bpy.ops.mesh.primitive_cube_add
layers = [False]*32
layers[0] = True
add_cube(location=(0,0,0), layer=layers)

bpy.context.active_object.rotation_mode=‘QUATERNION’
bpy.context.active_object.rotation_quaternion=[1, 0.5, 0, 0]
bpy.context.active_object.rotation_mode=‘XYZ’
bpy.context.active_object.rotation_euler = [1,1,1]

is this applicable to the selected object -
or may be the last created object ?

or may be to the group of selected object ?

Thanks

Aah, sorry zxo I must have forgotten that step

In my case, it is the last created object. I am not sure it is a correct way to get the object just created or not. Creating a underground mine system ( tunnels, stopes, pillars etc) is my goal.