Jump to content

Blender: batch naming while keeping LOD number


doc

Recommended Posts

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:


http://i.imgur.com/8d8OuLE.png


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?


download the zip from github and unpack it.

go to scripts/function/batch.py

around line 2576 https://github.com/trentinfrederick/name-panel/blob/master/scripts/function/batch.py#L2576


change:

[code2=python]# 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'):[/code2]

 

to:

 

[code2=python]# 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'):[/code2]

 

and around line 2595 https://github.com/trentinfrederick/name-panel/blob/master/scripts/function/batch.py#L2595


change:

[code2=python]# name

if hasattr(item[1][1], 'name'):

item[1][1].name = item[0]

elif hasattr(item[1][1], 'info'):[/code2]

 

to:

 

[code2=python]# name

if hasattr(item[1][1], 'name'):

item[1][1].name = item[0] + option.suffix

elif hasattr(item[1][1], 'info'):[/code2]

 

at last, around line 2646 https://github.com/trentinfrederick/name-panel/blob/master/scripts/function/batch.py#L2646


change:

 

[code2=python]# prefix & suffix

newName = option.prefix + newName + option.suffix[/code2]

 

to:

 

[code2=python]# prefix & suffix

newName = option.prefix + newName[/code2]

 

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:


http://i.imgur.com/S4b51Ez.png


I hope it will be useful!

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...