pyrna_enum_to_py: current value '20517' matches no enum in 'Event' #94658

Open
opened 2022-01-05 11:24:39 +01:00 by Jakub Uhlik · 13 comments

System Information
Operating system: macOS-10.13.6-x86_64-i386-64bit 64 Bits

Blender Version
Broken: version: 3.0.0, branch: master, commit date: 2021-12-02 18:35, hash: f1cca30557

Short description of error
WARN (bpy.rna): source/blender/python/intern/bpy_rna.c:1352 pyrna_enum_to_py: current value '20517' matches no enum in 'Event', '(null)', 'type'

Exact steps for others to reproduce the error
idea is: have mesh with attributes on vertices, have tool to select vertex and with gizmo manipulate said attributes (mostly custom rotation and scale that is later used in geometry nodes, maybe moving them around as well)

to replicate:

  • have active mesh object
  • run script
  • select Tool from toolbar
  • click on object to "select vertex"
  • drag gizmo arrow to "modify attribute"

this result in many warnings in console:
WARN (bpy.rna): source/blender/python/intern/bpy_rna.c:1352 pyrna_enum_to_py: current value '20517' matches no enum in 'Event', '(null)', 'type'

import bpy
import numpy as np
from mathutils import Vector, Matrix


class Manager():
    active = False


class MyModalOperator(bpy.types.Operator):
    bl_idname = "object.modal_operator"
    bl_label = "Simple Modal Operator"
    
    def modal(self, context, event):
        context.area.tag_redraw()
        
        if(event.type in {'ESC'}):
            Manager.active = False
            print('cancel')
            return {'CANCELLED'}
        elif(event.type in {'MIDDLEMOUSE', 'WHEELUPMOUSE', 'WHEELDOWNMOUSE'}):
            # navigation..
            return {'PASS_THROUGH'}
        elif(event.type == 'LEFTMOUSE' and event.value == 'PRESS'):
            print('modal')
            print(event.mouse_region_x, event.mouse_region_y)
            pass
        elif(event.type == 'SPACE' and event.value == 'PRESS'):
            Manager.active = False
            print('drop')
            return {'CANCELLED'}
        
        Manager.active = True
        
        return {'PASS_THROUGH'}
    
    def invoke(self, context, event):
        if(Manager.active):
            return {'CANCELLED'}
        
        print('invoke')
        print(event.mouse_region_x, event.mouse_region_y)
        
        if context.object:
            context.window_manager.modal_handler_add(self)
            return {'RUNNING_MODAL'}
        else:
            self.report({'WARNING'}, "No active object, could not finish")
            return {'CANCELLED'}


class MyTool(bpy.types.WorkSpaceTool):
    bl_space_type = 'VIEW_3D'
    bl_context_mode = 'OBJECT'
    
    bl_idname = "object.modal_operator"
    bl_label = "Tool"
    bl_description = ""
    bl_icon = "ops.generic.select_circle"
    bl_widget = "OBJECT_GGT_widget_test"
    bl_keymap = (
        (
            "object.modal_operator",
            {"type": 'LEFTMOUSE', "value": 'PRESS'},
            {"properties": []}
        ),
    )


class MyWidgetGroup(bpy.types.GizmoGroup):
    bl_idname = "OBJECT_GGT_widget_test"
    bl_label = "Test Widget"
    bl_space_type = 'VIEW_3D'
    bl_region_type = 'WINDOW'
    bl_options = {'3D'}
    
    @classmethod
    def poll(cls, context):
        if(not Manager.active):
            return False
        
        ob = context.object
        if(ob):
            return True
        return False
    
    def setup(self, context):
        ob = context.object
        gz = self.gizmos.new("GIZMO_GT_arrow_3d")
        
        def move_get():
            return ob.location.z
        
        def move_set(value):
            ob.location.z = value
        
        gz.target_set_handler("offset", get=move_get, set=move_set)
        
        v = Vector(ob.matrix_world @ Vector())
        v.z = v.z - gz.target_get_value("offset")[0]
        m = Matrix.Translation(v)
        gz.matrix_basis = m
        
        gz.color = 1.0, 1.0, 0.0
        gz.alpha = 0.5
        gz.color_highlight = 1.0, 1.0, 0.5
        gz.alpha_highlight = 0.5
        
        gz.use_draw_modal = True
        
        self.arrow = gz
    
    def refresh(self, context):
        ob = context.object
        gz = self.arrow
        
        v = Vector(ob.matrix_world @ Vector())
        v.z = v.z - gz.target_get_value("offset")[0]
        m = Matrix.Translation(v)
        gz.matrix_basis = m


def register():
    bpy.utils.register_class(MyWidgetGroup)
    bpy.utils.register_class(MyModalOperator)
    bpy.utils.register_tool(MyTool, after={"builtin.scale_cage"}, separator=True, group=True)


def unregister():
    bpy.utils.register_class(MyWidgetGroup)
    bpy.utils.unregister_class(MyModalOperator)
    bpy.utils.unregister_tool(MyTool, after={"builtin.scale_cage"}, separator=True, group=True)


if __name__ == "__main__":
    register()
**System Information** Operating system: macOS-10.13.6-x86_64-i386-64bit 64 Bits **Blender Version** Broken: version: 3.0.0, branch: master, commit date: 2021-12-02 18:35, hash: `f1cca30557` **Short description of error** WARN (bpy.rna): source/blender/python/intern/bpy_rna.c:1352 pyrna_enum_to_py: current value '20517' matches no enum in 'Event', '(null)', 'type' **Exact steps for others to reproduce the error** idea is: have mesh with attributes on vertices, have tool to select vertex and with gizmo manipulate said attributes (mostly custom rotation and scale that is later used in geometry nodes, maybe moving them around as well) to replicate: - have active mesh object - run script - select `Tool` from toolbar - click on object to "select vertex" - drag gizmo arrow to "modify attribute" this result in many warnings in console: WARN (bpy.rna): source/blender/python/intern/bpy_rna.c:1352 pyrna_enum_to_py: current value '20517' matches no enum in 'Event', '(null)', 'type' ``` import bpy import numpy as np from mathutils import Vector, Matrix class Manager(): active = False class MyModalOperator(bpy.types.Operator): bl_idname = "object.modal_operator" bl_label = "Simple Modal Operator" def modal(self, context, event): context.area.tag_redraw() if(event.type in {'ESC'}): Manager.active = False print('cancel') return {'CANCELLED'} elif(event.type in {'MIDDLEMOUSE', 'WHEELUPMOUSE', 'WHEELDOWNMOUSE'}): # navigation.. return {'PASS_THROUGH'} elif(event.type == 'LEFTMOUSE' and event.value == 'PRESS'): print('modal') print(event.mouse_region_x, event.mouse_region_y) pass elif(event.type == 'SPACE' and event.value == 'PRESS'): Manager.active = False print('drop') return {'CANCELLED'} Manager.active = True return {'PASS_THROUGH'} def invoke(self, context, event): if(Manager.active): return {'CANCELLED'} print('invoke') print(event.mouse_region_x, event.mouse_region_y) if context.object: context.window_manager.modal_handler_add(self) return {'RUNNING_MODAL'} else: self.report({'WARNING'}, "No active object, could not finish") return {'CANCELLED'} class MyTool(bpy.types.WorkSpaceTool): bl_space_type = 'VIEW_3D' bl_context_mode = 'OBJECT' bl_idname = "object.modal_operator" bl_label = "Tool" bl_description = "" bl_icon = "ops.generic.select_circle" bl_widget = "OBJECT_GGT_widget_test" bl_keymap = ( ( "object.modal_operator", {"type": 'LEFTMOUSE', "value": 'PRESS'}, {"properties": []} ), ) class MyWidgetGroup(bpy.types.GizmoGroup): bl_idname = "OBJECT_GGT_widget_test" bl_label = "Test Widget" bl_space_type = 'VIEW_3D' bl_region_type = 'WINDOW' bl_options = {'3D'} @classmethod def poll(cls, context): if(not Manager.active): return False ob = context.object if(ob): return True return False def setup(self, context): ob = context.object gz = self.gizmos.new("GIZMO_GT_arrow_3d") def move_get(): return ob.location.z def move_set(value): ob.location.z = value gz.target_set_handler("offset", get=move_get, set=move_set) v = Vector(ob.matrix_world @ Vector()) v.z = v.z - gz.target_get_value("offset")[0] m = Matrix.Translation(v) gz.matrix_basis = m gz.color = 1.0, 1.0, 0.0 gz.alpha = 0.5 gz.color_highlight = 1.0, 1.0, 0.5 gz.alpha_highlight = 0.5 gz.use_draw_modal = True self.arrow = gz def refresh(self, context): ob = context.object gz = self.arrow v = Vector(ob.matrix_world @ Vector()) v.z = v.z - gz.target_get_value("offset")[0] m = Matrix.Translation(v) gz.matrix_basis = m def register(): bpy.utils.register_class(MyWidgetGroup) bpy.utils.register_class(MyModalOperator) bpy.utils.register_tool(MyTool, after={"builtin.scale_cage"}, separator=True, group=True) def unregister(): bpy.utils.register_class(MyWidgetGroup) bpy.utils.unregister_class(MyModalOperator) bpy.utils.unregister_tool(MyTool, after={"builtin.scale_cage"}, separator=True, group=True) if __name__ == "__main__": register() ```
Author

Added subscriber: @JakubUhlik

Added subscriber: @JakubUhlik
Member

Added subscriber: @lichtwerk

Added subscriber: @lichtwerk
Member

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

Changed status from 'Needs Triage' to: 'Confirmed'
Philipp Oeser self-assigned this 2022-01-06 12:57:45 +01:00
Member

Can confirm, will check

Can confirm, will check
Philipp Oeser removed their assignment 2022-01-18 21:05:23 +01:00
Member

Will have to concentrate on triaging for a while (and step down).

Will have to concentrate on triaging for a while (and step down).
Member

#85606 ("event.type" prints warning when accessing unknown key types (e.g. UNKNOWNKEY)) is probably related.

#85606 ("event.type" prints warning when accessing unknown key types (e.g. UNKNOWNKEY)) is probably related.

Added subscriber: @z01ks

Added subscriber: @z01ks

Hello, I'm developing my own add-on that involves a Modal Operators and Gizmos and them running at the same time. I am getting the same error, after I use my gizmo for the second time. I am wondering if this error can be avoided? Or is this a known issue in blender that hasn't been fixed in this instance? Thanks.

Hello, I'm developing my own add-on that involves a Modal Operators and Gizmos and them running at the same time. I am getting the same error, after I use my gizmo for the second time. I am wondering if this error can be avoided? Or is this a known issue in blender that hasn't been fixed in this instance? Thanks.

Added subscriber: @1029910278

Added subscriber: @1029910278

I have this issue in 3.3 while develop my own custom gizmo but not in 3.2

I have this issue in 3.3 while develop my own custom gizmo but not in 3.2
Member

Added subscriber: @chaos-4

Added subscriber: @chaos-4
Member

I also have those errors in 3.3 with my addons when trying to access the Event object from a gizmo. This didn't happen to me in 3.2.
I can't simply get the values of event.type or event.value without being flooded with lots of these error messages.
In my case, I have these codes coming from source/blender/python/intern/bpy_rna.c:1334:

  • For type: 7640, 64, 66, -12672
  • For value: 1184
  • For type_prev: -1616, -15104, -2816
  • For value_prev: -289, 6296, -24042, -30529
I also have those errors in 3.3 with my addons when trying to access the Event object from a gizmo. This didn't happen to me in 3.2. I can't simply get the values of event.type or event.value without being flooded with lots of these error messages. In my case, I have these codes coming from source/blender/python/intern/bpy_rna.c:1334: - For type: 7640, 64, 66, -12672 - For value: 1184 - For type_prev: -1616, -15104, -2816 - For value_prev: -289, 6296, -24042, -30529
Philipp Oeser removed the
Interest
User Interface
label 2023-02-10 09:22:35 +01:00

Similar problem - when moving gizmo, that target geometry nodes modifier input 'Input_2' - throws lots of : '20517' matches no enum in 'Event' - in console (operation works though ok).

       def set_move_left(value):
            min_bounds = domain_mod[min_bounds_input] # min_bounds
            min_bounds[0] = self.min_x - value # min_bounds.x
            obj.update_tag(

        gizmo_left = self.gizmos.new("GIZMO_GT_arrow_3d")
        gizmo_left.target_set_handler("offset", get=lambda: 0, set=set_move_left)
Similar problem - when moving gizmo, that target geometry nodes modifier input 'Input_2' - throws lots of : '20517' matches no enum in 'Event' - in console (operation works though ok). ``` def set_move_left(value): min_bounds = domain_mod[min_bounds_input] # min_bounds min_bounds[0] = self.min_x - value # min_bounds.x obj.update_tag( gizmo_left = self.gizmos.new("GIZMO_GT_arrow_3d") gizmo_left.target_set_handler("offset", get=lambda: 0, set=set_move_left) ```
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
6 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#94658
No description provided.