Lack of bpy.props.IDProperty that could contain a reference to any Blender entity, as an object, material, scene... #34766

Closed
opened 2013-03-25 20:42:28 +01:00 by Emanuele Gissi · 6 comments

%%%This is not a bug, but an enhancement proposal. I could not find a better tool to propose it.

I would like to create a new bpy.types.Object property containing a link to a reference object.
As an example look at the "Object" field of the Boolean Modifier.
This is how I show the property in the panel:

row = layout.row()
row.prop_search(element,"my_reference_object",bpy.data,"objects")

This is how I create my new property:
bpy.types.Object.my_reference_object = StringProperty(name="Reference object")

This works, but if I change the name of the reference object, then the "my_reference_object" property is not updated, unlike what happens in the "Object" field of the Boolean Modifier. This is because I am just storing the name and not a pointer to the object.

I tried this:
bpy.types.Object.my_reference_object = PointerProperty(name="Reference object",type=bpy.types.Object)

but it does not work...

I thus suggest the creation of a bpy.props.IDProperty that could contain a reference to any Blender entity, as an object, material, scene...

Thank you as usual,
Emanuele Gissi%%%

%%%This is not a bug, but an enhancement proposal. I could not find a better tool to propose it. I would like to create a new bpy.types.Object property containing a link to a reference object. As an example look at the "Object" field of the Boolean Modifier. This is how I show the property in the panel: row = layout.row() row.prop_search(element,"my_reference_object",bpy.data,"objects") This is how I create my new property: bpy.types.Object.my_reference_object = StringProperty(name="Reference object") This works, but if I change the name of the reference object, then the "my_reference_object" property is not updated, unlike what happens in the "Object" field of the Boolean Modifier. This is because I am just storing the name and not a pointer to the object. I tried this: bpy.types.Object.my_reference_object = PointerProperty(name="Reference object",type=bpy.types.Object) but it does not work... I thus suggest the creation of a bpy.props.IDProperty that could contain a reference to any Blender entity, as an object, material, scene... Thank you as usual, Emanuele Gissi%%%
Author

Changed status to: 'Open'

Changed status to: 'Open'

%%%Hi Emanuele, first of all, this tracker is for bugs and is not really meant for feature requests.

However we're aware of this limitation and its been suggested before,
linking any data-type to any other data type adds a burden on the data manipulation functions - removing an object for eg would have to check if there is an ID in any id properly (object bones, pose bones for eg).
This could be managed by keeping track of what has ID-property references so it may be added at some point but isnt trivial.%%%

%%%Hi Emanuele, first of all, this tracker is for bugs and is not really meant for feature requests. However we're aware of this limitation and its been suggested before, linking any data-type to any other data type adds a burden on the data manipulation functions - removing an object for eg would have to check if there is an ID in any id properly (object bones, pose bones for eg). This could be managed by keeping track of what has ID-property references so it may be added at some point but isnt trivial.%%%

Changed status from 'Open' to: 'Resolved'

Changed status from 'Open' to: 'Resolved'
Author

%%%Thank you Bart. What tool do you suggest for future feature proposal? ("request" is too harsh ;-)
And ok for the reply, I am going to follow the StringProperty way.
Emanuele%%%

%%%Thank you Bart. What tool do you suggest for future feature proposal? ("request" is too harsh ;-) And ok for the reply, I am going to follow the StringProperty way. Emanuele%%%
Member

%%%It works in C-code (see e.g. boolean modifier, object property), so couldn't C-IDProps be wrapped for python, so that it's done all in C, but looks like it's python?%%%

%%%It works in C-code (see e.g. boolean modifier, object property), so couldn't C-IDProps be wrapped for python, so that it's done all in C, but looks like it's python?%%%

%%%It can work, but the obvious way to add will cause a lot of looping over data when removing ID blocks, since an id-property might contain an ID.%%%

%%%It can work, but the obvious way to add will cause a lot of looping over data when removing ID blocks, since an id-property might contain an ID.%%%
Sign in to join this conversation.
No Milestone
No project
No Assignees
3 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-addons#34766
No description provided.