0
$\begingroup$

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)
$\endgroup$
0
$\begingroup$

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)
$\endgroup$
1
  • $\begingroup$ Got it, thanks! $\endgroup$ – Stef Apr 3 at 20:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.