From 9ea630196c45cf15e3e292f391d0c69bef529eb2 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 18 Jan 2006 22:57:55 +0000 Subject: Fixed up naming new objects/meshes when that name alredy existed - faster and better new names. --- release/scripts/obj_import.py | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) (limited to 'release') 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(): -- cgit v1.2.3