ModelTranslator: 终审 Minor——sidecar 用 finally 清理 + average_islands_scale 补捕 TypeError
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.8
parent
7bab88a447
commit
1c9a7e1ed0
@@ -166,7 +166,7 @@ def _unwrap_seam(obj, warnings, seam_angle_deg=SEAM_ANGLE_DEG):
|
|||||||
warnings.append("minimize_stretch 不可用(%s),跳过松弛" % e)
|
warnings.append("minimize_stretch 不可用(%s),跳过松弛" % e)
|
||||||
try: # 统一纹素密度,避免大岛霸占分辨率
|
try: # 统一纹素密度,避免大岛霸占分辨率
|
||||||
bpy.ops.uv.average_islands_scale()
|
bpy.ops.uv.average_islands_scale()
|
||||||
except RuntimeError as e:
|
except (RuntimeError, TypeError) as e:
|
||||||
warnings.append("average_islands_scale 不可用(%s),跳过纹素均衡" % e)
|
warnings.append("average_islands_scale 不可用(%s),跳过纹素均衡" % e)
|
||||||
try:
|
try:
|
||||||
bpy.ops.uv.pack_islands(rotate=True, margin=PACK_MARGIN)
|
bpy.ops.uv.pack_islands(rotate=True, margin=PACK_MARGIN)
|
||||||
|
|||||||
@@ -40,10 +40,12 @@ def main():
|
|||||||
with open(s["uv_polys"], encoding="utf-8") as fp:
|
with open(s["uv_polys"], encoding="utf-8") as fp:
|
||||||
polys = _json.load(fp)
|
polys = _json.load(fp)
|
||||||
render_uv_png(polys, s["uv_preview"])
|
render_uv_png(polys, s["uv_preview"])
|
||||||
os.remove(s["uv_polys"])
|
|
||||||
print(" UV 观察图: %s" % s["uv_preview"])
|
print(" UV 观察图: %s" % s["uv_preview"])
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(" [警告] UV 观察图渲染失败:%s" % e)
|
print(" [警告] UV 观察图渲染失败:%s" % e)
|
||||||
|
finally: # sidecar 是内部临时文件,无论渲染成败都清掉
|
||||||
|
if os.path.exists(s["uv_polys"]):
|
||||||
|
os.remove(s["uv_polys"])
|
||||||
for w in s["warnings"]:
|
for w in s["warnings"]:
|
||||||
print(" [警告] %s" % w)
|
print(" [警告] %s" % w)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user