12
$\begingroup$

Since anything before and after the dot is arbitrary, why bother?

Related error:

RuntimeError: Error: Registering operator class: 'abcdefg', invalid bl_idname 'abcdefg', must contain 1 '.' character
$\endgroup$
9
$\begingroup$

This rule may seem arbitrary, but looks like there's already some structure in existing operator's names. All registered operators will end up within bpy.ops module, and we can see that identifiers directly under it is reserved for modules/namespaces further categorizing the operators:

When we need an operator to quit Blender, it's available, grouped with other window management operators.

At first I, too, didn't bother with naming, putting everything under bpy.ops.object. But namespace distinction really helps to document, browse and search all the operators. Predictable identifier + Python console's Autocomplete feature made it easier to discover and build upon existing operators, including those from other addons.

I don't know if it has any other significance, but self-documentation alone made the naming rule worthwhile to enforce.

$\endgroup$
9
$\begingroup$

Developer note: in C code blenders operators are formatted SOME_OT_operator, which gets converted to some.operator in Python. To ensure the conversion can be done the "." needs to be added.

Then we can expose all operators as bpy.ops.some.operator() too, which is neat/logical.

This is arbitrary and we could have chosen not to do it, but I think having each tool in a named category is a good thing.

$\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.