最近工作有需要用到python程式, 而blender也可用到, 真是太好了.
測試第一支python程式. 上方選單選擇scripting模式.
會帶出這樣的視窗 2.56版, 下方視窗用來直接輸入指令.
##CONTINUE##autocomplete的用處在只需打一部份的function名, 例如bpy.context.object.rotation
按下autocomplete, 自動跑出可用的function.

變數說明
radius : 半徑
angle : monkey旋轉的總角度
interval: 間隔角度
用來複製的function: bpy.ops.mesh.primitive_monkey_add
將以下script內容貼到Text edit中, 或是存成py檔再呼叫出來
duplicate_monkey.py 內容----------------
import bpy
from bpy import context
from math import sin,cos,radians
z = 0
radius = 5
angle = 7200
interval = 6
add_monkey = bpy.ops.mesh.primitive_monkey_add
cursor = context.scene.cursor_location
AngleInRadius = [radians(degree) for degree in range(0,angle,interval)]
for theta in AngleInRadius:
x = cursor.x+radius*cos(theta)
y = cursor.y+radius*sin(theta)
z += .2
add_monkey(view_align=False, enter_editmode=False, location=(x, y, z), rotation=(0, 0, 0))
按下run script, 猴子成螺旋狀複製出來,像是screw modifier, 該好好K數學了
2.52版有個好處, 會有report功能, 當你對物體動作時會出現指令.下圖為移動cube後產生的.
參考教學:http://mostly3d.wordpress.com/2010/11/22/blender-2-5-introduction-to-python-scripting-tutorial/
沒有留言:
張貼留言