2
$\begingroup$

I've recently searching about drawing template lists and find this question:
Populate a list with custom property dictionary data
but a thing that caught my atention was the name for the class "OBJECT_ul_zones" it remenbed others name I have seen with the same pattern: "TYPE_Class_classname" like OBJECT_OT_someoperator

Then came the question: what are the naming conventions for class and variables in Blender?

$\endgroup$
5
$\begingroup$

The use of strict class naming is more prevalent within blenders source code than within third party addons. While CamelCase is common I don't think there is a strong convention for class names, however, the name used in bl_idname is visible and used within blender so does have some conventions, with a view to also help prevent naming clashes.

For a panel the convention is CATEGORY_PT_name and if not set will be the class name. Similarly, menus use CATEGORY_MT_name. Common categories are Object, Mesh and Material. Both of these can often be found duplicated into class names, often using class names instead of setting bl_idname. Within blender's builtin operators you will find most use this naming (with CAT_OT_name) for operator classes. There are also examples of CAT_UL_name used for UILists.

For an operator, the bl_idname must be two words separated by a ., the first word should be a category while the second is the operator name. Operator bl_idnames are added to bpy.ops so if you have bl_idname='mesh.beautify' then the operator can be called from python with bpy.ops.mesh.beautify() and is added to a panel with layout.operator('mesh.beautify').

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.