Blender Python Add-on 〜チュートリアル2-2〜
前回は、アドオンのチュートリアルを始めました。(Your Second Add-on)
今回は、Your Second Add-onの2回目をやります。
→次のスクリプトの写経です。
Addon Tutorial — Blender 2.78.0 e8299c8 - API documentation
今回のスクリプトは、選択したオブジェクトをカーソルの位置までに
オブジェクトを作成して並べるスクリプトでした。
import bpy
from bpy import context
# よく使うものを変数に取り出します。
# this scene => in this 3dview
scene = context.scene
# cursor position of circle which red and white stripe
cursor = scene.cursor_location
# object of selected
obj = scene.objects.active
# 選択しているオブジェクトからカーソルの位置まで5個作成
total = 5
for i in range(total):
obj_new = obj.copy()
scene.objects.link(obj_new)
# Now place the objection between the cursor
# and the active object based on "i"
factor = i / total
obj_new.location = (obj.location * factor) + (cursor * (1.0 - factor))
以上、ちょっと計算が入るスクリプトでした。
次回は、アドオンとして作成します。