Class naming conventions in Blender 2.8 Python API

In Blender 2.8 API the requirements for the class and their identifiers naming are becoming tougher. The class name must match the following convention:

Where the {SEPARATOR} is two letters denoting the class belonging to a certain type (from which type the class is inherited):

  • HT – Header
  • MT – Menu
  • OT – Operator
  • PT – Panel
  • UL – UI list

The class identifier “bl_idname” mast match the class name.

Examples of valid class names and identifiers:

If class name or identifier doesn’t meet the conventions, Blender signals with error:

‘Oscurart Files Tools’ doesn’t contain ‘_PT_’ with prefix & suffix

0 0 votes
Article Rating
Subscribe
Notify of
guest
6 Comment
Newest
Oldest Most Voted
Inline Feedbacks
View all comments
Rombout Versluijs
Rombout Versluijs
4 months ago

I keep finding this inconsstent and its very very confusing. Here an example with Meny type. It returns this  ‘enr_mt_notification’ doesn’t contain ‘_MT_’ with prefix & suffix
Yet when i do add a dot say enr.mt_notification, its show the same? Also some operator dont need it and others do, The template example dont have and dont show any issue?!

Rombout Versluijs
Rombout Versluijs
4 months ago

Here i adjust it to mt.mt_notification and still shows the error.

I also tried this enrich.enr_mt_notification

This name convention is driving me nuts

Rombout Versluijs
Rombout Versluijs
4 months ago

Checking for instance modal uvmesh template. there is NO _OT_ not in the class name nor the bl_idname, it runs fine

when i do this with this above sample, bam again this error

Heres that sample from blender. class name and id name are totally different. Why does this work without blender nagging about it. I find this so vague and frustrating

Last edited 4 months ago by Rombout Versluijs
Rombout Versluijs
Rombout Versluijs
4 months ago

Got it working now without the warnings… this is why i find it confusing, its 2 way different implementations. Where as the operator does need a dot but not the prefix or suffix. its feels not consistent to me

Nikita
Editor
4 months ago

Name conversation for operators is different than for menus/panels/etc. Operators required “.” others – no.

Rombout Versluijs
Rombout Versluijs
4 months ago
Reply to  Nikita

I got it to work, no more errors. It wasnt clear for me that the operators were still using the regular naming with the dot. Especially when the errors show “doesnt contain _OT_” prefix. I think i understand it now