This shows you the differences between two versions of the page.
| Both sides previous revision Previous revision Next revision | Previous revision | ||
|
blender:python:addonnotes:start [2022/02/07 18:56] dwheele [How to Make Meshes with Python in Blender] |
blender:python:addonnotes:start [2022/02/19 18:19] (current) dwheele [Blender Python Addon Notes] |
||
|---|---|---|---|
| Line 1: | Line 1: | ||
| ====== Blender Python Addon Notes ====== | ====== Blender Python Addon Notes ====== | ||
| * [[..start|Full Blender Python notes]] | * [[..start|Full Blender Python notes]] | ||
| + | * [[https:// | ||
| Doing research to make a panel to control Baking Texture assignments. | Doing research to make a panel to control Baking Texture assignments. | ||
| Line 120: | Line 121: | ||
| </ | </ | ||
| + | ===== Blender member variables ===== | ||
| + | ^BL Variable^Example^Description^ | ||
| + | |bl_context|uv|The context in which the panel belongs to| | ||
| + | |bl_idname|VIEW3D_PT_test_1|Name of the object. Unique identifier for buttons and menu items to reference.. If this is set, the panel gets a custom ID, otherwise it takes the name of the class used to define the panel. For example, if the class name is “OBJECT_PT_hello”, | ||
| + | |bl_label|Panel One|Display name in the interface. Name of the object, shows up in a menu. The panel label, shows up in the panel header at the right of the triangle used to collapse the panel| | ||
| + | |bl_space_type|VIEW_3D|The space the panel will be used in. enum in [‘EMPTY’, | ||
| + | |bl_region_type|UI|The region where the panel is going to be used in. enum in [‘WINDOW’, | ||
| + | |bl_category|Tool|The category (tab) in which the panel will be displayed, when applicable. Leave blank if panel doesn' | ||
| + | |bl_options|DEFAULT_CLOSED|One of DEFAULT_CLOSED, | ||
| + | |bl_region_type|WINDOW|enum in [‘WINDOW’, | ||
| + | |||
| + | |||
| + | ===== register, unregister ===== | ||
| + | |||
| + | **To register a Python class,** so that it can be used within Blender, this function needs to run when the Python file is loaded. This means it is at the same level as the class defintion, that is, not indented. | ||
| + | |||
| + | <code python> | ||
| + | def register(): | ||
| + | bpy.utils.register_class(LayoutDemoPanel) | ||
| + | </ | ||
| + | |||
| + | **To unregister a Python class,** so that it disappears from the menuing, you typically use something like this: | ||
| + | |||
| + | <code python> | ||
| + | def unregister(): | ||
| + | bpy.utils.unregister_class(LayoutDemoPanel) | ||
| + | </ | ||
| + | |||
| + | but when run **from the Blender Python text editor**, the class doesn' | ||
| + | |||
| + | Note that " | ||
| + | |||
| + | <code python> | ||
| + | def unregister(): | ||
| + | myPanelClass = bpy.types.Panel.bl_rna_get_subclass_py(" | ||
| + | bpy.utils.unregister_class(myPanelClass ) | ||
| + | </ | ||
| + | |||
| + | ===== Python' | ||
| + | |||
| + | ^Variable^Description^ | ||
| + | |< | ||
| + | |||
| + | So we include this at the end of a Python script so that when running inside of Blender, it registers this class. Otherwise it doesn' | ||
| + | |||
| + | <code python> | ||
| + | if __name__ == " | ||
| + | register() | ||
| + | </ | ||