fix(utils): disable destructive modifier override correction that was clearing material assignments

This commit is contained in:
2026-06-02 23:22:49 +02:00
parent d40e3f0a0c
commit 024f6f9ad4

View File

@@ -49,94 +49,10 @@ def _restore_fragile_sockets(mod, snapshot):
def fix_lib_overrides():
fixed = 0
for obj in bpy.data.objects:
if not obj.modifiers:
continue
for mod in obj.modifiers:
if mod.type != 'NODES' or not mod.node_group:
continue
if not hasattr(mod.node_group, 'interface'):
continue
# Disabled as forcing "True" or "Index" onto generic modifier properties
# destroys the library overrides and clears all material assignments.
return 0
ng = mod.node_group
iface = getattr(ng, 'interface', None)
if not iface or not hasattr(iface, 'items_tree'):
continue
# Snapshot fragile sockets BEFORE any writes
snapshot = _snapshot_fragile_sockets(obj, mod, iface)
name_to_sid = {}
for item in iface.items_tree:
if item.item_type == 'SOCKET' and item.in_out == 'INPUT':
name_to_sid[item.name] = (item.identifier, item.socket_type)
for item in iface.items_tree:
if item.item_type != 'SOCKET' or item.in_out != 'INPUT':
continue
sid = item.identifier
if sid not in mod:
continue
stored = mod[sid]
st = item.socket_type
tt = type(stored).__name__
if st == 'NodeSocketBool' and tt == 'int':
mod[sid] = bool(stored)
fixed += 1
elif st == 'NodeSocketMenu' and tt == 'int':
mod[sid] = int(stored)
fixed += 1
ng_name = ng.name
if ng_name == "Add Shader v1.0":
if "Filter by ID" in name_to_sid:
sid = name_to_sid["Filter by ID"][0]
if mod.get(sid) != True:
mod[sid] = True
fixed += 1
if "ID" in name_to_sid and name_to_sid["ID"][1] == "NodeSocketString":
sid = name_to_sid["ID"][0]
if mod.get(sid) != "Index":
mod[sid] = "Index"
fixed += 1
elif ng_name in ["Add Shaders by Index v1.0", "Make Material", "Make Labels"]:
if "ID" in name_to_sid and name_to_sid["ID"][1] == "NodeSocketString":
sid = name_to_sid["ID"][0]
if mod.get(sid) != "Index":
mod[sid] = "Index"
fixed += 1
if ng_name == "Make Labels" and "Shrinkwrap" in name_to_sid:
sid = name_to_sid["Shrinkwrap"][0]
if mod.get(sid) != True:
mod[sid] = True
fixed += 1
elif ng_name == "Make attached":
if "Reset Children" in name_to_sid:
sid = name_to_sid["Reset Children"][0]
if mod.get(sid) != True:
mod[sid] = True
fixed += 1
if "Separate Children" in name_to_sid:
sid = name_to_sid["Separate Children"][0]
if mod.get(sid) != True:
mod[sid] = True
fixed += 1
elif ng_name == "Proxy v1.0":
if "Reset Children" in name_to_sid:
sid = name_to_sid["Reset Children"][0]
if mod.get(sid) != True:
mod[sid] = True
fixed += 1
# Restore any fragile sockets that got wiped
restored = _restore_fragile_sockets(mod, snapshot)
if restored:
print(f" [RESTORE] {obj.name}/{mod.name}: "
f"restored {restored} Material/Object sockets")
fixed += restored
return fixed
def fix_missing_images():