Hello
I want to create an "image texture" node in cycles for each material of each object and that it is selected. my script does not recognize my variable "allMat". I do not understand why. Thank you:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
    def execute(self, context):
        row1 =400
        col1 =500
        selection = bpy.context.selected_editable_objects
        bpy.ops.object.select_all(action='DESELECT')
 
 
 
        for obj in selection:
            if obj.type == 'MESH':
                myMat = obj.material_slots
                for allMat in myMat:
                    obj.select = True
                    img = obj.name
                    newBake=obj.active_material
                    newBake.use_nodes=True
 
                    TreeNodes=newBake.node_tree
                    links = TreeNodes.links
 
                    texEnter = TreeNodes.nodes.new('ShaderNodeTexImage')
                    texEnter.location = col1-1000, row1
                    texEnter.image = bpy.data.images[img]
                    a = bpy.data.materials[str(allMat)].node_tree.nodes['Image Texture']
                    a.select = False
 
 
 
        return {'FINISHED'}