Open enzyme69 opened 4 years ago
import bpy
sel = bpy.context.selected_objects
for ob in sel:
mat = ob.active_material
if mat:
ob.active_material = mat.copy()
for ts in mat.texture_slots:
try:
ts.texture = ts.texture.copy()
if ts.texture.image:
ts.texture.image = ts.texture.image.copy()
except:
pass
Original Thread from BA: https://blenderartists.org/t/make-materials-single-user-via-code/524068/5
Additional idea from Benny Goaverts to try
Blender 2.82 example making single user material and image texture for sequence
import bpy
from random import randrange
# bpy.data.objects['Plane'].material_slots[0].material.node_tree.nodes['Image Texture'].image_user.frame_offset = frame
sel = bpy.context.selected_objects
for ob in sel:
mat = ob.active_material
if mat:
# make single user for each material
ob.active_material = mat.copy()
# make single user texture for each material
ob.active_material.node_tree.nodes['Image Texture'].image = ob.active_material.node_tree.nodes['Image Texture'].image.copy()
# make cyclic
ob.active_material.node_tree.nodes['Image Texture'].image_user.use_cyclic = True
# randomize start frame
randval = randrange(0, 101, 2)
print(randval)
ob.active_material.node_tree.nodes['Image Texture'].image_user.frame_start = randval