From 8fe8ab4d4a92520e24a248042c187a8d9778be1f Mon Sep 17 00:00:00 2001 From: Mikko Rasa Date: Tue, 13 Apr 2021 12:02:24 +0300 Subject: [PATCH] Ensure that objects have unique names while exporting a scene --- blender/io_mspgl/export_scene.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/blender/io_mspgl/export_scene.py b/blender/io_mspgl/export_scene.py index 18cdcbca..2ec85ccb 100644 --- a/blender/io_mspgl/export_scene.py +++ b/blender/io_mspgl/export_scene.py @@ -30,6 +30,7 @@ class SceneExporter: object_prototypes = {} unique_objects = [] export_names = {} + used_names = set() for o in objs: if o.name in object_prototypes: continue @@ -54,12 +55,23 @@ class SceneExporter: prefix = prefix[:pos] if prefix: - export_names[o.name+".object"] = prefix.strip(" .")+".object" + export_names[o.name+".object"] = prefix.strip(" .") + else: + used_names.add(o.name) unique_objects.append(o) for c in clones: object_prototypes[c.name] = o + for n, e in export_names.items(): + if e in used_names: + number = 1 + while "{}_{}".format(e, number) in used_names: + number += 1 + e += "_{}".format(number) + export_names[n] = e+".object" + used_names.add(e) + from .util import Progress progress = Progress(self.show_progress and context) -- 2.45.2