assign default vray material


#21

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


#22

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 :slight_smile: I think this can be a satisfying way to get into coding


#23

Thanks u so much, worked. :heart_eyes:
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 :grin:
Thanks for your time bro.


#24

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


#25

I failed, =|

I m failed :confused:


#26

I’ve changed this much but still in the box (rollout) I couldn’t execute a direct command without a dialogue window. Without dialogue, I have to assign only shortcut to all objects and a default VRayMtl element. Help me edit this code please?

macroScript AssignVRayMaterial
category:“Medit Tools”
tooltip:“Assign VRay Material”
(
rollout ro_assign_material “Assign VRay Mtl” width:120 height:40
(
button bt_default “Default” pos:[8,8] width:104 height:24
local AssignMat
global vrnames
fn IntToString pInt = formattedPrint pInt format:“03d”
fn AssignMat asCopy:false type:#default =
(
if vrnames == undefined do vrnames = #(1,1,1)
if selection.count > 0 do
(
case type of
(
#default:
(
mat = VRayMtl Diffuse:[50,50,50] Reflection:[200,200,200] name:(“VrayMtl_” + IntToString vrnames[2]) Reflection_glossiness:0.5
vrnames[2] += 1
)
)
for o in selection do o.Material = if asCopy then copy mat else mat
)
)
on bt_default pressed do AssignMat type:#default
)
createdialog ro_assign_material style:#(#style_titlebar, #style_toolwindow, #style_sysmenu)
)


#27

Last edit

macroScript AssignVRayMaterial
category:“Medit Tools”
tooltip:“Assign VRay Material”
(
rollout ro_assign_material “VrayMtl” width:80 height:40
(
button bt_default “Assign” pos:[8,8] width:70 height:24
local AssignMat
fn AssignMat asCopy:off type:#default =
(
if selection.count > 0 do
(
#default:
mat = VRayMtl Diffuse:[50,50,50] Reflection:[200,200,200] name:“VrayMtl” Reflection_glossiness:0.5
for o in selection do o.Material = if asCopy then copy mat else mat
)
)
on bt_default pressed do AssignMat type:#default
)
)

please, help me clear rollout menu


#28

Save this as mcr file and drag and drop it onto 3ds max viewports. Then add a hotkey to it.
Select some objects and use the hotkey.

macroScript AssignVRayMaterial
category:"Medit Tools"
tooltip:"Assign VRay Material"
(	
	on execute do
	(
		if selection.count > 0 do
		(
			mat = VRayMtl Diffuse:[50,50,50] Reflection:[200,200,200] name:"VrayMtl" Reflection_glossiness:0.5
			selection.material = mat	
-- 			for o in selection do o.Material = mat
		)
	)
)

#29

Finally amazing, thanks you so much bro. :heart: