From 9d1fa012a23693768bbe287371e97751c03acc50 Mon Sep 17 00:00:00 2001 From: Mikko Rasa Date: Sat, 1 Jun 2019 15:55:28 +0300 Subject: [PATCH] Better naming algorithm for objects in scene export Arbitrary prefixes can cut words or numbers in silly places. Only allow truncating at common separator characters. --- blender/io_mspgl/export_scene.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/blender/io_mspgl/export_scene.py b/blender/io_mspgl/export_scene.py index 9b36c48f..245d2d3e 100644 --- a/blender/io_mspgl/export_scene.py +++ b/blender/io_mspgl/export_scene.py @@ -39,10 +39,11 @@ class SceneExporter: prefix = o.name for c in clones: - for i in range(min(len(c.name), len(prefix))): - if c.name[i]!=prefix[i]: - prefix = prefix[:i] - break + while not c.name.startswith(prefix): + pos = max(prefix.rfind(' '), prefix.rfind('.')) + if pos<0: + break; + prefix = prefix[:pos] if prefix: export_names[o.name+".object"] = prefix.strip(" .")+".object" -- 2.45.2