3
$\begingroup$

Can someone tell me why this code doesn't work?

I would like to use my object "Camera" as a projector in my modifier "UVProject"

import bpy

bpy.ops.object.modifier_add(type='UV_PROJECT')
bpy.context.object.modifiers["UVProject"].object = "Camera"
$\endgroup$
3
$\begingroup$

The value you are trying to set is a collection so you have to choose an index as you can have several projectors, use:

bpy.ops.object.modifier_add(type='UV_PROJECT')
bpy.context.object.modifiers["UVProject"].projectors[0].object = bpy.data.objects["Camera"]

See bpy.types.UVProjectModifier.

$\endgroup$

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.