From 8f3a94589e0b204412069664f94f9d545f2f79d0 Mon Sep 17 00:00:00 2001 From: Mark Eggert <72320499+TikiBear@users.noreply.github.com> Date: Sun, 4 Oct 2020 12:19:45 -0700 Subject: [PATCH 1/2] Update mesh.py Prevent export of Blender Decimate modifier from failing and corrupting Blender file! --- korman/exporter/mesh.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/korman/exporter/mesh.py b/korman/exporter/mesh.py index cb7d388..e5392f0 100644 --- a/korman/exporter/mesh.py +++ b/korman/exporter/mesh.py @@ -178,7 +178,7 @@ class _MeshManager: for cached_mod in override["modifiers"]: mod = bo.modifiers.new(cached_mod["name"], cached_mod["type"]) for key, value in cached_mod.items(): - if key in {"name", "type"}: + if key in {"name", "type"} or (cached_mod["type"] == "DECIMATE" and key=="face_count"): # Decimate attribute face_count is read-only continue setattr(mod, key, value) From 9b061154dc687e82fb00e91f050c62480a0f7a52 Mon Sep 17 00:00:00 2001 From: Mark Eggert <72320499+TikiBear@users.noreply.github.com> Date: Mon, 5 Oct 2020 12:45:44 -0700 Subject: [PATCH 2/2] Update mesh.py Fix Blender Decimate mod crash. Better syntax. --- korman/exporter/mesh.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/korman/exporter/mesh.py b/korman/exporter/mesh.py index e5392f0..b0a5da2 100644 --- a/korman/exporter/mesh.py +++ b/korman/exporter/mesh.py @@ -174,11 +174,12 @@ class _MeshManager: trash_mesh, bo.data = bo.data, data_meshes.get(override["mesh"]) data_meshes.remove(trash_mesh) - # If modifiers were removed, reapply them now. + # If modifiers were removed, reapply them now unless they're read-only. + readonly_attributes = {("DECIMATE", "face_count"),} for cached_mod in override["modifiers"]: mod = bo.modifiers.new(cached_mod["name"], cached_mod["type"]) for key, value in cached_mod.items(): - if key in {"name", "type"} or (cached_mod["type"] == "DECIMATE" and key=="face_count"): # Decimate attribute face_count is read-only + if key in {"name", "type"} or (cached_mod["type"], key) in readonly_attributes: continue setattr(mod, key, value)