[Bf-python] Saving a pointer to another object as a property
Michael Kleiber
michael.kleiber at fkie.fraunhofer.de
Mon Jan 31 17:39:00 CET 2011
Hi all,
I would like to save as an object's property a link/pointer to another
object. I want to display a UI element that lets the user choose an
object and which will then be saved as a property of the currently
selected object.
I only succeeded in showing a UI selection element which saves the name
of the selected object as a string. This means when the user changes the
name later, the name will be invalidated.
How can I save a pointer to an object?
Kind Regards,
Michael
SNIP
Example code I use to get the objects name. The commented out parts do
not work.
>>>
import bpy
bpy.types.Object.myName = bpy.props.StringProperty()
#bpy.types.Object.myLink = bpy.props.PointerProperty(type=bpy.types.Object)
class GetObjectByPointer(bpy.types.Panel):
bl_label = "Save Object Pointer"
bl_space_type = "VIEW_3D"
bl_region_type = "TOOLS"
bl_context = "objectmode"
def draw(self, context):
layout = self.layout
col = layout.column(align=True)
col.label("Select objects to get a link to")
col.prop_search(context.object, "myName", bpy.data, "objects")
#col.prop_search(context.object, "myLink", bpy.data, "objects")
More information about the Bf-python
mailing list