mercredi 26 juin 2019

Blender code: loop by index


 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
import bpy
print("*****************")
print("This Loop Trough Multi Materials")

selection = bpy.context.object
print("SELECTED OBJECT: "+selection.name)
index = -1
for m in selection.material_slots:
    index += 1
    bpy.context.object.active_material_index=index
    mat = bpy.context.object.active_material
    print(mat)

1 commentaire:

  1. In python, there is also 'enumerate' that allows not to count index by hand, for ex :

    for index, m in enumerate(selection.material_slots):
    ...

    RépondreSupprimer