Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender-addons.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBastien Montagne <montagne29@wanadoo.fr>2019-01-10 17:25:16 +0300
committerBastien Montagne <montagne29@wanadoo.fr>2019-01-10 17:26:18 +0300
commit9448cef00d1b3ac3e4c58e7278d726fd9d2f95da (patch)
treee9a1d08c9855b31d369e357997c0ee93e487d0d1 /io_scene_obj
parent2e9f1abbe7dcee90d3d0b3ce9fc950da9f656fe2 (diff)
Fix first part of T60381: OBJ import broken in case of multiple OBJ objects named the same.
Ensure we use a different key for each OBJ object (usung similar naming increment as Blender one).
Diffstat (limited to 'io_scene_obj')
-rw-r--r--io_scene_obj/__init__.py2
-rw-r--r--io_scene_obj/import_obj.py14
2 files changed, 13 insertions, 3 deletions
diff --git a/io_scene_obj/__init__.py b/io_scene_obj/__init__.py
index 166cc7fc..7fcb0a97 100644
--- a/io_scene_obj/__init__.py
+++ b/io_scene_obj/__init__.py
@@ -21,7 +21,7 @@
bl_info = {
"name": "Wavefront OBJ format",
"author": "Campbell Barton, Bastien Montagne",
- "version": (3, 5, 3),
+ "version": (3, 5, 4),
"blender": (2, 80, 0),
"location": "File > Import-Export",
"description": "Import-Export OBJ, Import OBJ mesh, UV's, materials and textures",
diff --git a/io_scene_obj/import_obj.py b/io_scene_obj/import_obj.py
index a065f7e1..8050b683 100644
--- a/io_scene_obj/import_obj.py
+++ b/io_scene_obj/import_obj.py
@@ -856,6 +856,14 @@ def load(context,
This function passes the file and sends the data off
to be split into objects and then converted into mesh objects
"""
+ def unique_name(existing_names, name_orig):
+ i = 0
+ name = name_orig
+ while name in existing_names:
+ name = b"%s.%03d" % (name_orig, i)
+ i += 1
+ existing_names.add(name)
+ return name
def handle_vec(line_start, context_multi_line, line_split, tag, data, vec, vec_len):
ret_context_multi_line = tag if strip_slash(line_split) else b''
@@ -908,6 +916,8 @@ def load(context,
context_object = None
context_vgroup = None
+ objects_names = set()
+
# Nurbs
context_nurbs = {}
nurbs = []
@@ -1086,12 +1096,12 @@ def load(context,
elif line_start == b'o':
if use_split_objects:
- context_object = line_value(line_split)
+ context_object = unique_name(objects_names, line_value(line_split))
# unique_obects[context_object]= None
elif line_start == b'g':
if use_split_groups:
- context_object = line_value(line.split())
+ context_object = unique_name(objects_names, line_value(line_split))
# print 'context_object', context_object
# unique_obects[context_object]= None
elif use_groups_as_vgroups: