Introduction to Maya - Rendering in Arnold
This course will look at the fundamentals of rendering in Arnold. We'll go through the different light types available, cameras, shaders, Arnold's render settings and finally how to split an image into render passes (AOV's), before we then reassemble it i
# 1 29-01-2015 , 11:50 AM
Registered User
Join Date: Mar 2007
Posts: 1,055

Multi-assign new materials to a number of objects?

Hi,

instead of assigning each object a new material individually, is there a way to assign a unique material to all objects in a scene?

For my purposes it doesn't matter what the material is, just that every one is unique to the object it's assigned too.

If anyone can help out I'd really appreciate it,

thank you,

g

# 2 29-01-2015 , 02:06 PM
EduSciVis-er
Join Date: Dec 2005
Location: Toronto
Posts: 3,374
A little script should be just the thing:

Code:
string $selectedObjs[] = `ls -sl`; //get selected objects
for ($obj in $selectedObjs){ //iterate on selected objects
	string $newMat = `shadingNode -asShader "lambert"`; //create a lambert
	string $rnMat = `rename $newMat ($obj + "_Lmb_Mat")`; //rename new material based on object [optional]
	string $newSG = `sets -renderable true -noSurfaceShader true -empty -name ($rnMat + "SG")`; //create a shading group
	connectAttr -f ($rnMat + ".outColor") ($newSG + ".surfaceShader"); //connect shading group to lambert
	sets -e -forceElement $newSG $obj; //connect material to object
}

# 3 29-01-2015 , 02:15 PM
Registered User
Join Date: Mar 2007
Posts: 1,055
Wow, that was awesome and fast, thank you so much Stewrt user added image

Much appreciated, does exactly what I needed!

thank you

gubar

# 4 29-05-2021 , 10:29 AM
Registered User
Join Date: May 2021
Posts: 1

A little script should be just the thing:

Code:
string $selectedObjs[] = `ls -sl`; //get selected objects
for ($obj in $selectedObjs){ //iterate on selected objects
	string $newMat = `shadingNode -asShader "lambert"`; //create a lambert
	string $rnMat = `rename $newMat ($obj + "_Lmb_Mat")`; //rename new material based on object [optional]
	string $newSG = `sets -renderable true -noSurfaceShader true -empty -name ($rnMat + "SG")`; //create a shading group
	connectAttr -f ($rnMat + ".outColor") ($newSG + ".surfaceShader"); //connect shading group to lambert
	sets -e -forceElement $newSG $obj; //connect material to object
}

such a lifesaver little script.. should be there in hypershade menu by default!
Thanks

Posting Rules Forum Rules
You may not post new threads | You may not post replies | You may not post attachments | You may not edit your posts | BB code is On | Smilies are On | [IMG] code is On | HTML code is Off

Similar Threads