Material based mesh renaming

Post Reply
Zafar Iqbal
Moderator
Posts: 169
Joined: 26 Oct 2009, 10:04

Material based mesh renaming

Post by Zafar Iqbal » 12 Sep 2011, 18:02

I'd like to name my meshes based on their applied material names. Is there any script available to do such a thing or could some scripting wizard be kind enough to create such a script?

Thanks,
- Zafar Iqbal

User avatar
Hirazi Blue
Administrator
Posts: 5107
Joined: 04 Jun 2009, 12:15

Re: Material based mesh renaming

Post by Hirazi Blue » 12 Sep 2011, 20:38

Something simple like this Python snippet? Appends the material name to the existing object name.

Code: Select all

howmany = Application.Selection.Count
for i in range(0, howmany):
	thisobj = Application.Selection(i)
	thismat = thisobj.Material.Name
	thisobj.Name = str(thisobj.Name) + "_" + str(thismat)
One or more geometries need to be selected, it obviously doesn't do error checking (costs extra! :D )
Throw it into a custom command, if needed
Use at own risk, obviously, I spent about 30 seconds testing this code... :!!
Stay safe, sane & healthy!

Zafar Iqbal
Moderator
Posts: 169
Joined: 26 Oct 2009, 10:04

Re: Material based mesh renaming

Post by Zafar Iqbal » 12 Sep 2011, 21:11

Awesome. Thanks a bunch for this, it worked like a charm and super fast on the 139 objects I just tried it on, all from different models/hierarchy levels.

Thanks ^:)^
- Zafar Iqbal

Post Reply

Who is online

Users browsing this forum: No registered users and 7 guests