Heya I want to create and assign material to selected object. But If I'm assigning the same material to 2 objects I'm creating 2 materials instead of assignign 1 mat to 2 objects. Can some1 look at my errors?
[CODE]
fn mats =
(
(
for o in getCurrentSelection() do (
try (
o.material = Arch___Design__mi ()
o.material.name ="TestMat"
o.material.diff_weight = 0.02
o.material.refl_weight = 1
o.material.refr_weight = 0.9
o.material.refl_func_fresnel = on
o.material.opts_1sided = on
o.material.opts_propagate_alpha = on
o.material.opts_refl_depth = 10
o.material.opts_refr_depth = 10
) catch()
)
)
)
mats()
[\CODE]
Comments (7)
Comment policy
Yeah
I thought I would script in python, but looking how little info of it is on internet I decided to move back to maxscript :(
Python scripting is very similar to mxs. But I not found any use in max for now.
.NET is very well integrated in max. I hope that AD will add Python IDE to work inside max side by side with mxs editor
Wow that was simple... damn thanks ! Ure the best! :- ))))
fn matAssign matName diffWeight = if selection.count != 0 do
(
material = if (sm = sceneMaterials[matName]) != undefined then sm else
(
Arch___Design__mi name:matName diff_weight:diffWeight refl_weight:1 refr_weight:.9 \
refl_func_fresnel:on opts_1sided:on opts_propagate_alpha:on opts_refl_depth:10 opts_refr_depth:10
)
for o in selection do o.mat = material
)
matAssign "test" 0.7
Hey
Thanks!
So this "almost" (:-))works great if I select all objects and assign a material. But if I select 3 objects, assign and then another 2 objects and assign I'm still getting duplicated material.
I was thinking that I need an if statement so
That works if material exists but the else function fails to create material if it dont exists.
Also this test :
Also this test function seems to have a weird problem.
If I DONT have the material in scene I get undefined. But when I have the material in scene on 1st execution I get undefined and on second execution I get "mat exists" printed. Is that normal that I need to run it 2x so that I get accurate value? :-(
I come from python scripting pipeline. I did MS for max 5 years ago and the code I posted originally worked for Vray just fine. Its frustrating how MR works :(
Can you hint me out how to fix the if statement? I want to avoid duplication of materials.
For better readability of any posted code folow this rule
http://www.scriptspot.com/forums/3ds-max/general-scripting/kredka-strike…
assign material as copy to all selected objects
assign material as instance to all selected objects