Blender Python 〜 開発メモ〜
記載している、記事と違って普通にメモ用です。
タイトル部に「開発メモ」と記載しているものに関してはメモです(笑)
Operators (bpy.ops) — Blender 2.79.0 855d2955c49 - API documentation
クラス一覧↑
マテリアル追加スクリプト: bpy.ops.object.material_slot_add()
PythonでのBoolean(Bool)の表示方法: print("this is %r" + bool(True / False)
【言語の設定処理】
# ローカライズのチェックボックスオンとオフ
bpy.context.user_preferences.system.use_international_fonts = True / False
# インターフェースを対象にするボタン
bpy.context.user_preferences.system.use_translate_interface = True / Flase
# 言語の設定
bpy.context.user_preferences.system.language = "ja_JP" / "en_US"
The example in your Blender will help you, see.
Text Editor > Templates > Python > Operator Mesh Uv
【日本語化】
下記、チェックボックスをチェックするコマンド
bpy.context.user_preferences.system.use_international_fonts = True
bpy.context.user_preferences.system.use_international_fonts = False #外す
言語部分を変更する
py.context.user_preferences.system.language = 'ja_JP' # 日本語
py.context.user_preferences.system.language = 'en_US' # 英語(アメリカ)
「インターフェース」
bpy.context.user_preferences.system.use_translate_interface = True / False
bpy.context.user_preferences.system.use_translate_tooltips = True / False
2018/03/14: Operator.unregister()起動時に
AttributeError: module 'ZstTools.RootOperator' has no attribute 'unregister'
解決
→ register, unregisterをクラス内のメソッド として定義しない
→ boy.utils.unregister_classで作成したクラスを削除する
blender 関連ページ
パネルにコンポーネント追加
https://wiki.blender.org/index.php/Dev:Py/Scripts/Cookbook/Panels_and_Operators/Ping_Pong
https://wiki.blender.org/index.php/Dev:Py/Scripts/Guidelines/Addons
https://docs.blender.org/manual/en/dev/modeling/modifiers/index.html
【アクションコマンドメモ】
「オブジェクトの角度を変更する」
import math
bpy.context.object.rotation_euler = math.radians(角度)
「イメージファイルへのアクセス」
bpy.data.images[image_index]
「モディファイヤーへのアクセス」
bpy.types.Modifier.bl_rna.properties['type'].enum_items
【アドオンの作成時につまづいたところ】
draw時に記載しないで起動したらエラーがでた。
self.layout.operator_context = "INVOKE_DEFAULT"でも「self.layout.operator」を使用しなければエラーは出ない。
Panelクラスのdraw()で入力のたびに下記のログが出力される