Notifications
Clear all

[Closed] assign default vray material

Hi PolyTools3D, Glossiness 0.5 how can i add? thank you

I don’t have the answer off the top of my head (it’ll be something like glossinessAmount) but a quick way of finding out is you turn on the macrorecorder and then make the change you need manually in material editor, you’ll see the code you need

Is it possible? thank you for answering

Yes, turn on the macro recorder in the maxscript listener, do the change manually in material editor, then look at the maxscript listener.

It will show you the line of code you need to change glossiness, then you can add it to the script

I didn’t understand what you said because unfortunately i can’t write code, so sorry

No probs, but I can’t help much I’m afraid – I don’t have Vray installed on my machine at the moment. If you can find out what the maxscript listener says, I can tell you where to put it in @PolyTools3D ‘s code.

You just have to go to Scripting->MacroRecorder to turn the recorder on.

Then open material editor, make a vray material, change the glossiness value or whatever it is you want to change.

Then open the maxscript listener (Scripting->Maxscript Listener) and look for any code that says something about glossiness. Copy and paste that here

actionMan.executeAction 0 “50048” – Tools: Material Editor Toggle
rootScene[#SME][#View1][#Material__40____VRayMtl].Properties.reference.Diffuse = color 50 50 50
rootScene[#SME][#View1][#Material__40____VRayMtl].Properties.reference.Reflection = color 200 200 200
rootScene[#SME][#View1][#Material__40____VRayMtl].Properties.reference.reflection_glossiness = 0.5
actionMan.executeAction 0 “40472”

thank you so much bro

Ok, so in @PolyTools3D ‘s code, anywhere where it says “mat = VrayMtl ” you can add reflection_glossiness:0.5 at the end – so for the chrome option, the default option or the white option. Like this:

 					 #chrome:
 					(
 						mat = VRayMtl Diffuse:[0,0,0] Reflection:[229,229,229] name:("Vraychrome_" + IntToString vrnames[1]) reflection_glossiness:0.5
 						vrnames[1] += 1
 					)
 					 #default:
 					(
 						mat = VRayMtl Diffuse:[128,128,128] name:("Vraygray_" + IntToString vrnames[2]) reflection_glossiness:0.5
 						vrnames[2] += 1  
 					)
 					#white:
 					(
 						mat = VRayMtl Diffuse:[220,220,220] name:("Vraywhite_" + IntToString vrnames[3]) reflection_glossiness:0.5
 						vrnames[3] += 1  
 					)

Give that a go and play around with it a bit I think this can be a satisfying way to get into coding

Thanks u so much, worked.
but, “rollout” opened popup menu and 3 materials available. i need u without popup just one material, only shortcut and assign one default material. i m editing try, i hope it work
Thanks for your time bro.

You’re welcome. Maybe it’s faster for you to start with the code posted at the start of this thread:

(
 	-- Create a test object
 	obj = Sphere()
 	
 	-- Create a new VRay material
 	mat = VRayMtl()
 	
 	-- Change the Diffuse color to Black
 	mat.Diffuse = [0,0,0]
 	
 	-- Change the Reflection value to 90%
 	mat.Reflection = [255,255,255] * 0.9
 
 	-- Assign the VRay material to the Object
 	obj.Material = mat
 )

Of course you need to add your

mat.reflection_glossiness = 0.5

And instead of making a sphere and applying the material at the end of the code, you could just stick the material in the first material editor slot with

meditmaterials[1] = mat

so you can use it however you want.

or another example, you could assign it directly to a selected object with

$.mat = mat

Page 2 / 3