There are no custom classes in bpy.types #76606

Closed
opened 2020-05-10 07:16:25 +02:00 by Sergey · 8 comments

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: 13e3a1c532

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'
**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: `13e3a1c532` **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' ```
Author

Added subscriber: @randum

Added subscriber: @randum
Sergey changed title from There is no custom classes in bpy.types to There are no custom classes in bpy.types 2020-05-10 07:19:36 +02:00

Added subscriber: @ideasman42

Added subscriber: @ideasman42

Changed status from 'Needs Triage' to: 'Resolved'

Changed status from 'Needs Triage' to: 'Resolved'
Campbell Barton self-assigned this 2020-05-11 10:25:33 +02:00

Added note in docs: f4d65b0d6e

Added note in docs: f4d65b0d6e
Author

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
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 ```
Member

Added subscriber: @Calra

Added subscriber: @Calra
Member

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

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

@Calra Yes it works. Thanks a lot. I was close to figure it out by myself.

@Calra Yes it works. Thanks a lot. I was close to figure it out by myself.
Sign in to join this conversation.
No Label
Interest
Alembic
Interest
Animation & Rigging
Interest
Asset Browser
Interest
Asset Browser Project Overview
Interest
Audio
Interest
Automated Testing
Interest
Blender Asset Bundle
Interest
BlendFile
Interest
Collada
Interest
Compatibility
Interest
Compositing
Interest
Core
Interest
Cycles
Interest
Dependency Graph
Interest
Development Management
Interest
EEVEE
Interest
EEVEE & Viewport
Interest
Freestyle
Interest
Geometry Nodes
Interest
Grease Pencil
Interest
ID Management
Interest
Images & Movies
Interest
Import Export
Interest
Line Art
Interest
Masking
Interest
Metal
Interest
Modeling
Interest
Modifiers
Interest
Motion Tracking
Interest
Nodes & Physics
Interest
OpenGL
Interest
Overlay
Interest
Overrides
Interest
Performance
Interest
Physics
Interest
Pipeline, Assets & IO
Interest
Platforms, Builds & Tests
Interest
Python API
Interest
Render & Cycles
Interest
Render Pipeline
Interest
Sculpt, Paint & Texture
Interest
Text Editor
Interest
Translations
Interest
Triaging
Interest
Undo
Interest
USD
Interest
User Interface
Interest
UV Editing
Interest
VFX & Video
Interest
Video Sequencer
Interest
Virtual Reality
Interest
Vulkan
Interest
Wayland
Interest
Workbench
Interest: X11
Legacy
Blender 2.8 Project
Legacy
Milestone 1: Basic, Local Asset Browser
Legacy
OpenGL Error
Meta
Good First Issue
Meta
Papercut
Meta
Retrospective
Meta
Security
Module
Animation & Rigging
Module
Core
Module
Development Management
Module
EEVEE & Viewport
Module
Grease Pencil
Module
Modeling
Module
Nodes & Physics
Module
Pipeline, Assets & IO
Module
Platforms, Builds & Tests
Module
Python API
Module
Render & Cycles
Module
Sculpt, Paint & Texture
Module
Triaging
Module
User Interface
Module
VFX & Video
Platform
FreeBSD
Platform
Linux
Platform
macOS
Platform
Windows
Priority
High
Priority
Low
Priority
Normal
Priority
Unbreak Now!
Status
Archived
Status
Confirmed
Status
Duplicate
Status
Needs Info from Developers
Status
Needs Information from User
Status
Needs Triage
Status
Resolved
Type
Bug
Type
Design
Type
Known Issue
Type
Patch
Type
Report
Type
To Do
No Milestone
No project
No Assignees
3 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: blender/blender#76606
No description provided.