Set all material's diffuse to white


#1

Hello,
I want to set diffuse color to white for all selection material.
I could set white by new material. But I want to overwrite existing material to keep texture.
Is there any way to do that?
thank you :slight_smile:

for o in selection do
(
     Rr= 255
     Rg= 255
     Rb= 255
     m = standardmaterial()
     m.diffuse = color Rr Rg Rb
     o.material = m
)

#2

Maybe like this:

(
	whiteClr = (color 255 255 255)
	for o in selection where (mat = o.material) != undedined do
	(
		
		case classOf mat of
		(
			standardMaterial: mat.diffuse = whiteClr
			coronaMtl: mat.colorDiffuse = whiteClr
			vrayMtl: mat.diffuse = whiteClr
		)
	)
)

#3

Hi sir, Thank you for your help :slight_smile:
Your script worked in single material! But it can’t work on multimat… :sweat:
Anything tips for me?
Thank you :slight_smile:


#4
(
	whiteClr = (color 255 255 255)
	for o in selection where (mat = o.material) != undedined do
	(		
		case classOf mat of
		(
			standardMaterial: mat.diffuse = whiteClr
			coronaMtl: mat.colorDiffuse = whiteClr
			vrayMtl: mat.diffuse = whiteClr
			Multimaterial:
			(
				for i = 1 to mat.numsubs do
				(
					case classOf mat[i] of
					(
						standardMaterial: mat[i].diffuse = whiteClr
						coronaMtl: mat[i].colorDiffuse = whiteClr
						vrayMtl: mat[i].diffuse = whiteClr
					)
				)
			)
		)
	)
)

#5

what if submaterial is also a multimaterial?


#6

Maybe the OP will solve this case and will post a solution. :slight_smile:


#7
for obj in selection do
(
	(mats = getclassinstances Standard target:obj).diffuse = white
)

#8

Hi, Thank you both! It worked.
I learned a lot :slight_smile: