3
$\begingroup$

I am 3D modelling a museum for a game, and I wanted to give every painting a unique texture. On each painting there are 2 different materials: the frame and the painting. I selected each individual painting and assigned it a different painting material, leaving the frame material as the same.

However after changing every single painting material to an individual material, I realized that the parts of the mesh that the painting material and the frame material are assigned on were swapped (each is assigned to the other's). I can't do ctrl + l because all of the individual paintings are going to change. I really do not want to delete them all and then re-add them.

I tried in a duplicate of the project and I couldn't fully delete the 70 materials I made. Is there a way to change the assignment of each painting, while keeping them assigned to their different materials? I also added material utilities, and couldn't find a way, but there might be one.

Some screenshots:

enter image description here

$\endgroup$

1 Answer 1

5
$\begingroup$

Make sure you're in object mode, then try running this script from the text editor. Save beforehand just in case.

import bpy
for mesh in bpy.data.meshes:
    for poly in mesh.polygons:
        poly.material_index = 1 - poly.material_index    
$\endgroup$
1
  • 2
    $\begingroup$ You cured all the pain in my body at once. Thankyou so much! $\endgroup$
    – object
    Commented Mar 13, 2021 at 8:32

You must log in to answer this question.

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