Page 1 of 1

### Blender: batch naming while keeping LOD number

Posted: Mon Feb 29, 2016 2:37 pm
I've always found quite annoying to name each single object while working in Blender.
Expecially when it comes to make a model for Torque.
If you are using trailing numbers for the LOD, you will quickly notice how splitting a mesh adds a .001,002 and such.

Say we want to make a huge TSStatic and we want it to be culled in parts, the result will be similar:

There's a cool utility called Name Panel, and can be found here: https://github.com/trentinfrederick/name-panel
You just have to select your objects, the hit space, batch name and select "selected", the little brownish cube and done.
No. Doesn't work with our LOD, it would number our shape as shapeLOD500.1 etc.

How to solve this problem?

go to scripts/function/batch.py
around line 2576 https://github.com/trentinfrederick/nam ... h.py#L2576

change:
# duplicates
if collection[item[1]][0] not in duplicates:

# name
if hasattr(collection[item[1]][1][1], 'name'):
collection[item[1]][1][1].name = collection[item[1]][0] + option.separator + '0'*option.padding + str(i + option.start).zfill(len(str(collection[item[1]][1][0])))
elif hasattr(collection[item[1]][1][1], 'info'):
to:
# duplicates
if collection[item[1]][0] not in duplicates:
# name
if hasattr(collection[item[1]][1][1], 'name'):
optSt = option.start-1
if(optSt < 0):
optSt = 0
trail = chr((i + optSt) + ord("A"));
collection[item[1]][1][1].name = collection[item[1]][0] + option.separator + '0'*option.padding + trail + option.suffix
elif hasattr(collection[item[1]][1][1], 'info'):
and around line 2595 https://github.com/trentinfrederick/nam ... h.py#L2595

change:
# name
if hasattr(item[1][1], 'name'):
item[1][1].name = item[0]
elif hasattr(item[1][1], 'info'):
to:
# name
if hasattr(item[1][1], 'name'):
item[1][1].name = item[0] + option.suffix
elif hasattr(item[1][1], 'info'):
at last, around line 2646 https://github.com/trentinfrederick/nam ... h.py#L2646

change:
# prefix & suffix
newName = option.prefix + newName + option.suffix
to:
# prefix & suffix
newName = option.prefix + newName
then install the script normally.
When you will run the batch name, it will append the suffix at the end of the object's name and adds a letter instead of a number. For instance:

CubeLOD300.1
CubeLOD300.2
CubeLOD300.3

will be:

Cube.ALOD300
Cube.BLOD300
Cube.CLOD300

just remove the "separator" from the field in the menu to an empty and the suffix to -LOD300 and you will have:

CubeA-LOD300
CubeB-LOD300 and so on.

the result with the previous example is now this:

I hope it will be useful!