othman alazzam othman alazzam - 2 years ago 107
Python Question

Loop doesn't work, 3-lines python code

this question is about blender, python scripting

I'm completely new in this, so please excuse me for any stupid/newbie question/comment.

I made it simple (3 lines code) to make it easy addressing the problem.

what I need is a code that adds a new uv map for each object within loop function.

But this code instead is adding multiple new UV maps to only one object.

import bpy
for x in bpy.context.selected_objects:

what's wrong I'm doing here??


Answer Source

The uv_texture_add operator is one that only works on the current active object. You can change the active object by setting scene.objects.active

import bpy
for x in bpy.context.selected_objects:
    bpy.context.scene.objects.active = x
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download