Blender Fix Script - Please copy and run after import! | X |
import bpy
for obj in bpy.data.objects:
bpy.ops.object.select_all(action='DESELECT') # deselect all objects
if obj.type=="EMPTY":
if len(obj.children)>0:
if obj.children[0].type=="MESH":
print(obj.children)
for child in obj.children:
child.select_set(True)
with bpy.context.temp_override(active_object=obj.children[0],selected_objects=obj.children):
bpy.ops.object.join()
print("JOINED: " + obj.name)
for mat in bpy.data.materials:
obj_set=[]
bpy.ops.object.select_all(action='DESELECT') # deselect all objects
for obj in bpy.data.objects:
if obj.users>0 and obj.parent==None and len(obj.material_slots)==1:
if obj.material_slots[0].name==mat.name:
obj_set.append(obj)
obj.select_set(True)
if len(obj_set)>0:
print(mat.name)
with bpy.context.temp_override(active_object=obj_set[0],selected_objects=obj_set):
bpy.ops.object.join()
print("JOINED: " + mat.name)
for mat in bpy.data.materials:
if mat.node_tree.nodes.get("Principled BSDF", None) is not None:
mat.node_tree.nodes["Principled BSDF"].inputs["Specular"].default_value = 0