Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import bpy
- for obj in bpy.data.objects:
- if obj.active_material is not None:
- if obj.active_material.name.startswith('textures'):
- print(obj.active_material.name)
- mat = obj.active_material
- tex = 0
- if mat.texture_slots[0] is not None:
- continue
- try:
- tex = bpy.data.textures[mat.name]
- except KeyError:
- tex = bpy.data.textures.new(mat.name, 'IMAGE')
- try:
- tex.image = bpy.data.images.load('path/to/assets/' + mat.name + '.jpg')
- except RuntimeError:
- print(mat.name + ' not found')
- continue
- slot = mat.texture_slots.add()
- slot.texture = tex
Add Comment
Please, Sign In to add comment