I am trying to create a script that involves the creation and setup of a UV Project modifier. When it comes to set the UV Map of the projector, there is no problem at all:

import bpy

bpy.context.object.modifiers["UVProject"].uv_layer = "UVMap"

But when I'm trying to set the projector object, I find no way to do it, as "projectors" property seems to be read-only:


Q: Am I missing something or precisely that property is just not scriptable?


1 Answer 1


Similar to How to add modifiers using python script and set parameters?, the recommended way is to add a new modifier to an object using ObjectModifiers.new() which returns the reference to the modifier and allows to assign whatever you like:

import bpy

# Get the object in context
obj = bpy.context.object

# Add the modifier to the object in context
modifier = obj.modifiers.new(name="project", type='UV_PROJECT')

# Properties
modifier.uv_layer = "UVMap"
modifier.projector_count = 10

for p in modifier.projectors:
    p.object = bpy.context.scene.camera

projectors property is of type bpy_prop_collection, which is essentially a list of object references. In order to assign an object to each Object property of the modifier, you would have to assign an object reference like bpy.context.scene.camera.

  • $\begingroup$ Thank you very much. It worked just fine and did what I was expecting. My strategy consisted of seeing the info window and try to copy/paste instructions into a script in order to automatize them, but it seems it is not working like this. Best regards $\endgroup$ Jan 28, 2021 at 19:25
  • $\begingroup$ Glad it helps @JaimeFinat $\endgroup$
    – brockmann
    Jan 28, 2021 at 19:51

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .