zxo102
(zxo102)
April 19, 2010, 7:26am
1
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
Jarrhead
(Jarrhead)
April 19, 2010, 7:48am
2
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.
zxo102
(zxo102)
April 19, 2010, 7:31pm
3
Jarrhead:
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.
Aligorith
(Aligorith)
April 19, 2010, 9:29pm
4
The rotation representations are currently mutually exclusive, with the rotation representation being used being specified by the rotation_mode setting.
zxo102
(zxo102)
April 19, 2010, 10:04pm
5
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
Jarrhead
(Jarrhead)
April 20, 2010, 6:53am
7
Aah, sorry zxo I must have forgotten that step
zxo102
(zxo102)
April 20, 2010, 7:26pm
8
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.