Hello guys! I’ve done this script to manage all the vray materials reflection and glossiness taken from an object selection, it works pretty well.
However when I tried to make it to search in multisubobject and vrayblend matearials I fail. Any suggestions?
This is the script
– Get selected objects
selected_objects = selection as array
– Get Vray materials from selected objects
vray_materials = for obj in selected_objects where classof obj.material == VRayMtl collect obj.material
– Define function to loop through sub-materials
fn loop_through_sub_materials material =
(
– Check for multisubobject material
if classof material == MultiMaterial do
(
for i = 1 to material.numsubs do
(
sub_material = material[i]
loop_through_sub_materials sub_material
)
)
– Check for blend material
else if classof material == VRayBlendMtl do
(
for i = 1 to material.numsubs do
(
sub_material = material.get_sub_material i
loop_through_sub_materials sub_material
)
)
– Apply changes to regular Vray material
else if classof material == VRayMtl do
(
– Set reflection amount
material.texmap_reflection_multiplier = reflection_amount.value
-- Set glossiness amount
material.texmap_reflectionGlossiness_multiplier = glossiness_amount.value
-- Set glossiness value
material.reflection_glossiness = glossiness_value.value
-- Set reflection color
material.reflection = reflection_color.color as color
)
)
– Define rollout
rollout vray_material_manager “Vray Material Manager”
(
– Reflection amount spinner
slider reflection_amount "Reflection Amount: " range:[0.0,100.0,0.0] type:#float
-- Glossiness amount spinner
slider glossiness_amount "Glossiness Amount: " range:[0.0,100.0,0.0] type:#float
-- Glossiness value spinner
slider glossiness_value "Glossiness Value: " range:[0.0,1.0,0.0] type:#float
-- Reflection color picker
colorPicker reflection_color "Reflection Color: "
-- Define sliders and color picker function
on reflection_amount changed val do
(
-- Loop through Vray materials and apply changes to sub-materials
for material in vray_materials do
(
loop_through_sub_materials material
)
)
on glossiness_amount changed val do
(
-- Loop through Vray materials and apply changes to sub-materials
for material in vray_materials do
(
loop_through_sub_materials material
)
)
on glossiness_value changed val do
(
-- Loop through Vray materials and apply changes to sub-materials
for material in vray_materials do
(
loop_through_sub_materials material
)
)
on reflection_color changed val do
(
-- Loop through Vray materials and apply changes to sub-materials
for material in vray_materials do
(
loop_through_sub_materials material
)
)
)
– Create rollout
createDialog vray_material_manager
And this was my attempt to make it to search inside multisubobjects and blend
– Get selected objects
selected_objects = selection as array
– Get Vray materials from selected objects
vray_materials = for obj in selected_objects where classof obj.material == VRayMtl collect obj.material
– Define function to loop through sub-materials
fn loop_through_sub_materials material =
(
– Check for multisubobject material
if classof material == MultiMaterial do
(
for i = 1 to material.numsubs do
(
sub_material = material[i]
loop_through_sub_materials sub_material
)
)
– Check for blend material
else if classof material == VRayBlendMtl do
(
for i = 1 to material.numsubs do
(
sub_material = material.get_sub_material i
loop_through_sub_materials sub_material
)
)
– Apply changes to regular Vray material
else if classof material == VRayMtl do
(
– Set reflection amount
material.texmap_reflection_multiplier = reflection_amount.value
-- Set glossiness amount
material.texmap_reflectionGlossiness_multiplier = glossiness_amount.value
-- Set glossiness value
material.reflection_glossiness = glossiness_value.value
-- Set reflection color
material.reflection = reflection_color.color as color
)
)
– Define rollout
rollout vray_material_manager “Vray Material Manager”
(
– Reflection amount spinner
slider reflection_amount "Reflection Amount: " range:[0.0,100.0,0.0] type:#float
-- Glossiness amount spinner
slider glossiness_amount "Glossiness Amount: " range:[0.0,100.0,0.0] type:#float
-- Glossiness value spinner
slider glossiness_value "Glossiness Value: " range:[0.0,1.0,0.0] type:#float
-- Reflection color picker
colorPicker reflection_color "Reflection Color: "
-- Define sliders and color picker function
on reflection_amount changed val do
(
-- Loop through Vray materials and apply changes to sub-materials
for material in vray_materials do
(
loop_through_sub_materials material
)
)
on glossiness_amount changed val do
(
-- Loop through Vray materials and apply changes to sub-materials
for material in vray_materials do
(
loop_through_sub_materials material
)
)
on glossiness_value changed val do
(
-- Loop through Vray materials and apply changes to sub-materials
for material in vray_materials do
(
loop_through_sub_materials material
)
)
on reflection_color changed val do
(
-- Loop through Vray materials and apply changes to sub-materials
for material in vray_materials do
(
loop_through_sub_materials material
)
)
)
– Create rollout
createDialog vray_material_manager