import bpy
# Get the objects
objects = bpy.context.selected_objects
# Set the base path
base_path = "C:/exportpakkio"
# Iterate over objects
for obj in objects:
# Check if object has an active material
if obj.active_material:
# Get the material
mat = obj.active_material
# Check if the material has a node tree
if mat.node_tree:
# Iterate over the nodes in the node tree
for node in mat.node_tree.nodes:
# Check if the node is a texture node and if its type is "TEX_IMAGE"
if node.type == 'TEX_IMAGE':
# Get the image
img = node.image
# Check if the image is not None
if img:
# Set the new path
new_path = base_path + "/" + img.name
# Save the image
img.filepath_raw = new_path
img.file_format = 'PNG'
print("saving ",new_path)
img.save()
Comments