I’m (still) struggling with my asset importing script, and I have hit a NEW snag: When I run the script on a list of assets to link in from various files, if I link the same asset in twice (here, I need TWO people to have a sandwich EACH, dun dun duuuuun…), I get an error stating that there already exists an objecct like that (instead of adding the usual .001 as is default for doubles). So I added a little routine to check a list for the name and rename (add a “_”) if needed. BUT… Now it just seems to either (A) rename the existing and new object both and then complain that an object of that name already exists, or (B) insert the new object anyway, erase the old one, and then complain.
chk = 
while l[0:4] != 'Make': filepath = cwd+"/Scenes/Assets/"+l[0:len(l)-1]+".blend" group_name = "Asset" with bpy.data.libraries.load(filepath, link=True) as (data_src, data_dst): data_dst.groups = [group_name] for o in data_dst.groups.objects: newobjname = l[0:len(l)-1] for n in chk: print (n) if n == newobjname: newobjname = newobjname+"_" chk.append(newobjname) print ("---") o.name = newobjname bpy.context.scene.objects.link(o) bpy.context.scene.update() l = f.readline()
(This is a segment of the larger script, but the rest should not be relevant to the issue at hand…)