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

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2006-01-19 01:57:55 +0300
committerCampbell Barton <ideasman42@gmail.com>2006-01-19 01:57:55 +0300
commit9ea630196c45cf15e3e292f391d0c69bef529eb2 (patch)
tree611bb55aece15619d2db1baf835fffb44d28aa52 /release
parent407fcf1e8c3e09b5679b330f3d2a952f441b756d (diff)
Fixed up naming new objects/meshes when that name alredy existed - faster and better new names.
Diffstat (limited to 'release')
-rw-r--r--release/scripts/obj_import.py23
1 files changed, 10 insertions, 13 deletions
diff --git a/release/scripts/obj_import.py b/release/scripts/obj_import.py
index ed0c0f34110..f2bcaf853e7 100644
--- a/release/scripts/obj_import.py
+++ b/release/scripts/obj_import.py
@@ -408,20 +408,14 @@ def load_mtl(dir, mtl_file, meshDict, materialDict):
# Returns unique name of object/mesh (preserve overwriting existing meshes) #
#===========================================================================#
def getUniqueName(name):
- newName = name
+ newName = name[:19] # 19 chars is the longest name.
uniqueInt = 0
- while 1:
- try:
- ob = Object.Get(newName)
- # Okay, this is working, so lets make a new name
- newName = '%s.%.3d' % (name, uniqueInt)
- uniqueInt +=1
- except ValueError:
- if newName not in NMesh.GetNames():
- return newName
- else:
- newName = '%s.%3d' % (name, uniqueInt)
- uniqueInt +=1
+ while newName in getUniqueName.uniqueNames:
+ newName = '%s.%.3i' % (name[:15], uniqueInt)
+ uniqueInt +=1
+ getUniqueName.uniqueNames.append(newName)
+ return newName
+getUniqueName.uniqueNames = []
#==================================================================================#
# This loads data from .obj file #
@@ -432,6 +426,9 @@ def load_obj(file, IMPORT_MTL=1, IMPORT_EDGES=1, IMPORT_SMOOTH_ALL=0):
time1 = sys.time()
+ getUniqueName.uniqueNames.extend( [ob.name for ob in Object.Get()] )
+ getUniqueName.uniqueNames.extend( NMesh.GetNames() )
+
# Deselect all objects in the scene.
# do this first so we dont have to bother, with objects we import
for ob in Scene.GetCurrent().getChildren():