]> git.tdb.fi Git - libs/gl.git/commitdiff
Don't rename scene objects while exporting
authorMikko Rasa <tdb@tdb.fi>
Fri, 16 Apr 2021 20:52:23 +0000 (23:52 +0300)
committerMikko Rasa <tdb@tdb.fi>
Sat, 17 Apr 2021 10:26:04 +0000 (13:26 +0300)
It's somewhat risky to come up with entirely new names.  Sorting the
objects by name already ensures that if one of the names is a prefix
for others, it gets used as the prototype name.

blender/io_mspgl/export_scene.py

index e272823ee164d257b1464a6f840ddb8a51e2e7cb..aa3c0c1963d1564ccde81faa1fb42d9c1ad44491 100644 (file)
@@ -16,33 +16,6 @@ class SceneExporter:
                path, base = os.path.split(out_fn)
                base, ext = os.path.splitext(base)
 
-               export_names = {}
-               used_names = set()
-               for p in scene.prototypes:
-                       clones = [i for i in scene.instances if i.prototype==p.name]
-
-                       prefix = p.name
-                       for c in clones:
-                               while not c.name.startswith(prefix):
-                                       pos = max(prefix.rfind(' '), prefix.rfind('.'))
-                                       if pos<0:
-                                               break;
-                                       prefix = prefix[:pos]
-
-                       if prefix:
-                               export_names[p.name+".object"] = prefix.strip(" .")
-                       else:
-                               used_names.add(p.name)
-
-               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)
 
@@ -51,10 +24,6 @@ class SceneExporter:
 
                resources = {}
                data_exporter.export_resources(context, scene.prototypes, resources, None, progress)
-               for n, r in resources.items():
-                       if r.name in export_names:
-                               r.name = export_names[r.name]
-
                scene_res = self.export_scene(scene, resources, progress)
                refs = scene_res.collect_references()