MEL script to assign a new material based on that objects name


#1

Does anyone know how you would go about making a script that allows you to assign a new material to an object? Not one material assigning to a batch of objects but rather a new material for each object that has the same name as the object. I’m just sick of having to assign and rename a new material for each and every object in my scene. Thanks


#2

Hi,

I try to get my head around what you mean, or trying to archieve, could you e.g. give an example?

do you mean e.g. select an Object named Box and then the material to be applied named BoxMat, or that an Object gets created and the Matrial that gets attached automaticaly to have the new name applied… e.g. creating a Object named Box (ObjectName) and at creation time the Material automatic gets assigned as BoxMat (ObjectNameMat).

or an exiting Material on the Object to be replaced on the Object, or that the Material on the Object should have the exact same name as the Object it is assigned to?

and how would you like it to work, at creation time, or by clicking the object or something completely else?

sorry for all these question, but trying to figure out what you are asking about. :slight_smile:

Kind regards

strarup