0
$\begingroup$

I'm trying to add a Pointer Property in my code that would be able to reference an Integer Property that exists on some data block of some object.

What is the proper way of doing it? I thought it should be as simple as the code below, but it doesn't work.

I do use PointerProperties a lot to reference specific object types etc., but I'm not sure how to point to a simple Int Property. How should I do it?

Thank you so much and I apologize if this is a trivial question.

enter image description here

import bpy
    
class Example_Class(bpy.types.PropertyGroup):
    
    int_pointer: bpy.props.PointerProperty(
        type=bpy.types.IntProperty,
        name="Int Property Pointer",
        description = "This is the pointer to Int Property that exists somewhere else",
    )    

def register():
    bpy.utils.register_class(Example_Class)    

 
def unregister():
    bpy.utils.unregister_class(Example_Class)
 
    
if __name__ == "__main__":
    register()

The error message is:

TypeError: PointerProperty(...) expected an RNA type derived from ID or ID Property Group
Error: Python: Traceback (most recent call last):
  File "\Text", line 20, in <module>
  File "\Text", line 12, in register
ValueError: bpy_struct "Example_Class" registration error: 'int_pointer' PointerProperty could not register (see previous error)
$\endgroup$
3
  • $\begingroup$ The Blender 3.x documentation is confusing and very vage about this because it tells you nothing about the type. If you check the old 2.79 documentation or enter bpy.props.PointerProperty( in the Python console and hit the Tab key then you will see ":arg type: A subclass of :class:bpy.types.PropertyGroup or :class:bpy.types.ID." - Basically the same as what the error message tells you. $\endgroup$
    – Blunder
    Dec 7, 2022 at 1:24
  • $\begingroup$ IntProperty(Property) has the base classes "bpy_struct" and "Property". That's the reason why it does not work. So you probably need to encapsulate it in another PropertyGroup. -- Related question and an answer: blender.stackexchange.com/a/6977/107598 $\endgroup$
    – Blunder
    Dec 7, 2022 at 1:30
  • $\begingroup$ Ahh!!! Got it! Thank you so much!!! $\endgroup$ Dec 8, 2022 at 20:18

0

You must log in to answer this question.

Browse other questions tagged .