Blender APIチートシート
公式APIリファレンス
docs.blender.org
Blender 3.2 Python API Documentation — Blender Python API
「ソース編集」がない
プリファレンス
→ インターフェース
→表示
から 開発者用オプション
を有効にする。
選択関係
選択されたオブジェクトを取得する
selection = bpy . context . selected_objects
マテリアルの取得
selection [ 0 ] . material_slots [ 0 ] . name
選択されたメッシュオブジェクトの頂点カラーデータの現在アクティブな頂点カラーレイヤーの0番目の頂点のBの値を0にする。
ただしEditModeからはアクセスできない。
bpy . context . selected_objects [ 0 ] . data . vertex_colors . active . data [ 0 ] . color [ 2 ] = 0
選択された頂点のリストを取得する
[ v for v in bpy . context . active_object . data . vertices if v . select ]
現在のモード
アドオン
サイドバーテンプレート
GitHub
Sidebar-Addon-Template-for-2.80/blender 28 sidebar template.py at master · slepyhed/Sidebar-Addon-Template-for-2.80
Here is a free template to setup a new tab on the sidebar for your next project. Please don't fork this, just download the zip. - Sidebar-Addon-Template-for-2.80/blender 28 sidebar template.py ...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47 import bpy
bl_info = {
"name" : "My tool" ,
"author" : "kurotori" ,
"version" : ( 0 , 1 , 0 ),
"blender" : ( 2 , 91 , 0 ),
"location" : "View3D > Sidebar > New Tab" ,
"description" : "My tool" ,
"warning" : "" ,
'wiki_url' : "https://github.com/" ,
'tracker_url' : 'https://github.com/' ,
"category" : "Animation"
}
class MyTemplatePanel ( bpy . types . Panel ):
bl_label = "MyTemplate"
bl_idname = "MyTemplate"
bl_space_type = 'VIEW_3D'
bl_region_type = 'UI'
bl_content = 'vertexpaint'
bl_category = "Category" # タブに表示される名前
def draw ( self , context ):
global gui_active_panel
scn = bpy . context . scene
icon_expand = "DISCLOSURE_TRI_RIGHT"
icon_collapse = "DISCLOSURE_TRI_DOWN"
self . layout . label ( text = "FOOTER AREA" )
classes = (
MyTemplatePanel ,
)
def register ():
for cls in classes :
bpy . utils . register_class ( cls )
def unregister ():
for cls in reversed ( classes ):
bpy . utils . unregister_class ( cls )
if __name__ == "__main__" :
register ()
ups = context.tool_settings.unified_paint_settings
prop_owner = ups if ups.use_unified_color else brush
parent.prop(prop_owner, prop_name, text=text)