Blenderstorm

Popular
In development
Implemented
Idea #133: Allow custom IDPropertyGroup-derived types use PointerProperty

Written by jesterKing the 29 Aug 10 at 08:13. Category: Python Scripting. Related project: Nothing/Others. Status: New
Rationale
It would be useful for scripters to have the ability to create custom types that also can have PointerProperty attributes that are ID blocks (other than IDPropertyGroup)

Currently this is not possible and forces scripters to think up kludges to somehow detect data pointers attached to their data.

I'd like to be able to do:

class MyType(bpy.types.IDPropertyGroup):
pass

MyType.object = PointerProperty(name='Object', type=bpy.types.Object)

Note, this is not for operator properties.

7
votes
up equal down
Solution #1: Allow PointerProperty to be set as property
Written by jesterKing the 29 Aug 10 at 08:13.
Make following possible by allowing PointerProperty to be added as property to custom type.

class MyType(bpy.types.IDPropertyGroup):
pass

MyType.object = PointerProperty(name='Object', type=bpy.types.Object)

mytypeinstance.object = bpy.data.objects[0]

In case a datablock gets deleted (pointer invalid) I propose to have lazy evaluation:
when the code accesses the PointerProperty either throw an exception or None, whichever is preferrable. This means there is no need to traverse IDs when changes happen to update the pointers.

Currently I lean towards None.

if mytypeinstance.object: # here underlying code can check and return None when pointer is invalid
[codebloc]


Propose your solution


Duplicates


Comments
jesterKing (Administrator) wrote on the 12 Sep 10 at 01:07
Updated example code to be according 2.54 RNA API


Post your comment
Syndicate content