Skip to main content
Tweeted twitter.com/StackBlender/status/1505242705605148672
Became Hot Network Question
deleted 1443 characters in body
Source Link
hilifit
  • 312
  • 1
  • 9

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.

Edit: It seems it's not possible to assign a pointer to a particle system, which means I would need to dynamically assign a new pointer property to the parent object when each particle system is created. This would be possible in my case, as I am creating each particle system programmatically. The issue would be linking each particle system to the correct pointer. I could use a unique ID for the attribute name, something like this:

def create_particle_system():
  context.object.modifiers.new(name='ps_name', 'PARTICLE_SYSTEM')
  id = str(hash(datetime.now()))
  setattr(bpy.types.Object, id, bpy.props.PointerProperty(type=bpy.types.Object, name=id))

But I would need a way to link the id value to the particle system somehow, so that when drawing the prop_search for each particle system, the relevant object pointer could be referenced.

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

Is there no way to assign a unique id to a particle system? Using the name or index wouldn't work, as they are subject to change, meaning the link between object pointer and particle system would be lost.

If I am fundamentally misunderstanding something here, please let me know.

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.

Edit: It seems it's not possible to assign a pointer to a particle system, which means I would need to dynamically assign a new pointer property to the parent object when each particle system is created. This would be possible in my case, as I am creating each particle system programmatically. The issue would be linking each particle system to the correct pointer. I could use a unique ID for the attribute name, something like this:

def create_particle_system():
  context.object.modifiers.new(name='ps_name', 'PARTICLE_SYSTEM')
  id = str(hash(datetime.now()))
  setattr(bpy.types.Object, id, bpy.props.PointerProperty(type=bpy.types.Object, name=id))

But I would need a way to link the id value to the particle system somehow, so that when drawing the prop_search for each particle system, the relevant object pointer could be referenced.

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

Is there no way to assign a unique id to a particle system? Using the name or index wouldn't work, as they are subject to change, meaning the link between object pointer and particle system would be lost.

If I am fundamentally misunderstanding something here, please let me know.

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.

added 4 characters in body
Source Link
hilifit
  • 312
  • 1
  • 9

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.

Edit: It seems it's not possible to assign a pointer to a particle system, which means I would need to dynamically assign a new pointer property to the parent object when each particle system is created. This would be possible in my case, as I am creating each particle system programmatically. The issue would be linking each particle system to the correct pointer. I could use a unique ID for the attribute name, something like this:

def create_particle_system():
  bpycontext.dataobject.modifiers.new(name='ps_name', 'PARTICLE_SYSTEM')
  id = str(hash(datetime.now()))
  setattr(bpy.types.Object, id, bpy.props.PointerProperty(type=bpy.types.Object, name=id))

But I would need a way to link the id value to the particle system somehow, so that when drawing the prop_search for each particle system, the relevant object pointer could be referenced.

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

Is there no way to assign a unique id to a particle system? Using the name or index wouldn't work, as they are subject to change, andmeaning the link between object pointer and particle system would be lost.

If I am fundamentally misunderstanding something here, please let me know.

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.

Edit: It seems it's not possible to assign a pointer to a particle system, which means I would need to dynamically assign a new pointer property to the parent object when each particle system is created. This would be possible in my case, as I am creating each particle system programmatically. The issue would be linking each particle system to the correct pointer. I could use a unique ID for the attribute name, something like this:

def create_particle_system():
  bpy.data.modifiers.new(name='ps_name', 'PARTICLE_SYSTEM')
  id = str(hash(datetime.now()))
  setattr(bpy.types.Object, id, bpy.props.PointerProperty(type=bpy.types.Object, name=id))

But I would need a way to link the id value to the particle system somehow, so that when drawing the prop_search for each particle system, the relevant object pointer could be referenced.

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

Is there no way to assign a unique id to a particle system? Using the name or index wouldn't work, as they are subject to change, and the link between object pointer and particle system would be lost.

If I am fundamentally misunderstanding something here, please let me know.

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.

Edit: It seems it's not possible to assign a pointer to a particle system, which means I would need to dynamically assign a new pointer property to the parent object when each particle system is created. This would be possible in my case, as I am creating each particle system programmatically. The issue would be linking each particle system to the correct pointer. I could use a unique ID for the attribute name, something like this:

def create_particle_system():
  context.object.modifiers.new(name='ps_name', 'PARTICLE_SYSTEM')
  id = str(hash(datetime.now()))
  setattr(bpy.types.Object, id, bpy.props.PointerProperty(type=bpy.types.Object, name=id))

But I would need a way to link the id value to the particle system somehow, so that when drawing the prop_search for each particle system, the relevant object pointer could be referenced.

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

Is there no way to assign a unique id to a particle system? Using the name or index wouldn't work, as they are subject to change, meaning the link between object pointer and particle system would be lost.

If I am fundamentally misunderstanding something here, please let me know.

added 1433 characters in body
Source Link
hilifit
  • 312
  • 1
  • 9

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.

Edit: It seems it's not possible to assign a pointer to a particle system, which means I would need to dynamically assign a new pointer property to the parent object when each particle system is created. This would be possible in my case, as I am creating each particle system programmatically. The issue would be linking each particle system to the correct pointer. I could use a unique ID for the attribute name, something like this:

def create_particle_system():
  bpy.data.modifiers.new(name='ps_name', 'PARTICLE_SYSTEM')
  id = str(hash(datetime.now()))
  setattr(bpy.types.Object, id, bpy.props.PointerProperty(type=bpy.types.Object, name=id))

But I would need a way to link the id value to the particle system somehow, so that when drawing the prop_search for each particle system, the relevant object pointer could be referenced.

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

Is there no way to assign a unique id to a particle system? Using the name or index wouldn't work, as they are subject to change, and the link between object pointer and particle system would be lost.

If I am fundamentally misunderstanding something here, please let me know.

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.

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.

Edit: It seems it's not possible to assign a pointer to a particle system, which means I would need to dynamically assign a new pointer property to the parent object when each particle system is created. This would be possible in my case, as I am creating each particle system programmatically. The issue would be linking each particle system to the correct pointer. I could use a unique ID for the attribute name, something like this:

def create_particle_system():
  bpy.data.modifiers.new(name='ps_name', 'PARTICLE_SYSTEM')
  id = str(hash(datetime.now()))
  setattr(bpy.types.Object, id, bpy.props.PointerProperty(type=bpy.types.Object, name=id))

But I would need a way to link the id value to the particle system somehow, so that when drawing the prop_search for each particle system, the relevant object pointer could be referenced.

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

Is there no way to assign a unique id to a particle system? Using the name or index wouldn't work, as they are subject to change, and the link between object pointer and particle system would be lost.

If I am fundamentally misunderstanding something here, please let me know.

edited body
Source Link
hilifit
  • 312
  • 1
  • 9
Loading
Source Link
hilifit
  • 312
  • 1
  • 9
Loading