Page MenuHome

There are no custom classes in bpy.types
Closed, ResolvedPublic

Description

System Information
Operating system: Windows-7-6.1.7601-SP1 64 Bits
Graphics card: GeForce GTX 660 Ti/PCIe/SSE2 NVIDIA Corporation 4.5.0 NVIDIA 416.34

Blender Version
Broken: version: 2.83 (sub 13), branch: master, commit date: 2020-04-21 17:59, hash: rB13e3a1c53222

Short description of error
I'm reading current documentation:
https://docs.blender.org/api/current/info_overview.html#class-registration

Once this class is loaded you can access it from bpy.types, using the bl_idname rather than the classes original name.

When I'm trying get my class I get attributeerror

Exact steps for others to reproduce the error

import bpy

class MyCustomTree(bpy.types.NodeTree):
    bl_idname = 'CustomTreeType'
    bl_label = "Custom Node Tree"
    bl_icon = 'NODETREE'

bpy.utils.register_class(MyCustomTree)
>>> bpy.types.CustomTreeType
Traceback (most recent call last):
  File "<blender_console>", line 1, in <module>
AttributeError: 'RNA_Types' object has no attribute 'CustomTreeType'

Event Timeline

Sergey (randum) renamed this task from There is no custom classes in bpy.types to There are no custom classes in bpy.types.May 10 2020, 7:19 AM

Can you clarify how this should be done in my example? According new note I'm writing something like this but it is raising the error:

>>> bpy.types.Struct.bl_rna_get_subclass('CustomTreeType')
Traceback (most recent call last):
  File "<blender_console>", line 1, in <module>
ValueError: Class type "Struct" not supported

@Sergey (randum) try bpy.types.NodeTree.bl_rna_get_subclass_py('CustomTreeType')

@Himanshi Kalra (calra) Yes it works. Thanks a lot. I was close to figure it out by myself.