Change Vray material properties on selected objects

I have a question about a litttle script that changes several Vray material properties at once. The current script I'm using changes all materials in the scene and works fine, but it would be very helpful to have the same script work on selected objects. A former colleague helped me with the original script. I can't figure this out by myself. I find the script very helpful when setting up a Vray-scene and I just change, add or disable properties as needed.

Any help would be highly appreciated!:)

(
	fn doif mat=
	(
		if classof mat==vraymtl then
		(
			format "navn %\n" mat.name
			mat.option_traceReflection=true
			mat.reflection_glossiness=0.8
			mat.reflection_fresnel=true
			mat.reflection=color 255 255 255
			mat.reflection_subdivs = 16
			mat.texmap_bump_multiplier = 5
			mat.texmap_bump = VRayEdgesTex ()
			mat.texmap_bump.widthType = 0
			mat.texmap_bump.thickness = 0.1
		)
	)
	for i in scenematerials do
	(
		if classof i==multimaterial then
		(
			for j in i.materialList do
			(
				doif j
			)
		)
		else if classof i==vraymtl then
		(
			doif i
		)
	)
)

Thanks in advance!

Comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Leamus's picture

Wow, thanks, this will be so

Wow, thanks, this will be so helpfull! Works like a charm!

barigazy's picture

...

As you see now you are not limited to multimaterial and default vrMat.
This work for any case. I mean nested vrMat.
Cheers!

barigazy

Leamus's picture

Genius, thank you!

Genius, thank you!

barigazy's picture

...

Try this

	fn doif mat=
	(
		format "navn %\n" mat.name
		mat.option_traceReflection = mat.reflection_fresnel = on
		mat.reflection_glossiness = 0.8
		mat.reflection = white
		mat.reflection_subdivs = 16
		mat.texmap_bump_multiplier = 5
		mat.texmap_bump = VRayEdgesTex widthType:0 thickness:.1
	)
	if selection.count > 0 do
	(
		for o in selection where o.mat != undefined do
		(
			material = getClassInstances vraymtl target:o.mat
			if material.count != 0 do for m in material do doif m
		)
	)

barigazy

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.