3
$\begingroup$

I'm trying to register an object pointer to type ParticleSystem, so that I can use it for a prop_search, but the pointer is set to read-only by default, which causes an error. Here is a simplified example of what I'm doing:

def register():
  bpy.types.ParticleSystem.my_pointer = bpy.types.PointerProperty(type=bpy.types.Object, name="My Pointer")

def draw_panel(self, context):
  for ps in context.object.particle_systems:
    box = layout.box()
    box.prop(ps, "name")
    box.prop_search(ps, "my_pointer", context.scene, "objects", icon="OBJECT_DATA", text="target object")

The boxes and particle system names are rendered, but the prop_search throws an error and isn't rendered.

Here is the error:

<_PropertyDeferred, <built-in function PointerProperty>, {'type': <class 'bpy_types.Object'>, 'name': 'My Pointer'}>
rna_uiItemPointerR: property not found: ParticleSystem.my_pointer

If I try to set the value of the pointer in the console it tells me that the property is read-only.

Is there a workaround for this? How can I have an object pointer that is unique for each particle system? I'm looking for a solution that doesn't rely on particle system names.

$\endgroup$

1 Answer 1

3
$\begingroup$

The manual section for Property Definitions says

Custom properties can be added to any subclass of an ID, Bone and PoseBone.

but bpy.types.ParticleSystem only inherits from bpy.struct and that doesn't inherit from any of the allowed classes.

So your code is failing because you can't add a property to the particle system type.

$\endgroup$
2
  • $\begingroup$ So there is no way to identify particle systems other than name or index? $\endgroup$
    – hilifit
    Commented Mar 18, 2022 at 19:39
  • $\begingroup$ Not that I'm aware of. But perhaps you could edit your question and explain what it is you want the identifier for and why the name or index won't do. $\endgroup$ Commented Mar 18, 2022 at 19:45

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .