1

I have created a PointerProperty so that I can specify a target object that I want a my script to act on, but I can't seem to find any information about how to actually use the pointer property once I have it.

I have created the property in the register() function:

bpy.types.Scene.targetObject = PointerProperty(type=bpy.types.Object)

And I'm drawing it successfully in my tool's control panel:

tool panel

But how do I actually operate on the selected object? ie:

# throws error "AttributeError: 'tuple' object has no attribute 'name'
print(bpy.types.Scene.targetObject.name)
Stef
  • 13
  • 2

1 Answers1

3

bpy.types.Scene has a property targetObject that is a PointerProperty. That means instances of bpy.types.Scene have a property targetObject that is a bpy.types.Object (or None).

# This prints the targetObject for the current scene
print(bpy.context.scene.targetObject)
scurest
  • 10,349
  • 13
  • 31