Hello,
I am trying to make a script to copy what ever is in a slot to an other one, ive made something that kind of works but it is strange, the listener return a result that make you think that it works but when you check on the material itself nothing happens, if i replace the variable a and b , with “mat.baseBumpTexmap = copy mat.baseTexmap” then it works, it is effectively copying the diffusemap to the bump mat of the selected object materials but its not working when i use variables a and b instead , the strange thing is that the listener return the same info about the name of the bitmap that has been copied in both case.
i am new to maxscript and i didn’t find anything in maxhelp that could help me understand what’s going on.
here is the code :
rollout progressTest "Corona copy material slot"
(
radiobuttons copy_fromRB labels:#("Base color", "Base Roughness", "Base anisotropy", "Base aniso. rot", "Base IOR", "Edgecolor", "Transl. fraction", "Transl.color", "Metalness", "refraction am.",
"thin abs.color", "opacity", "Self-illumination", "Base bump", "Displacement", "Clearcoat am.", "Clearcoat IOR", "Clearcoat rough.", "Clearcoat abs.", "Clearcoat bump", "Sheen amount", "Sheen color",
"Sheen rough.", "SSS amount", "SSS radius", "SSS scatt. color", "Vol. absorption", "Vol.scattering", "Base tail", "Reflect BG override", "Refract BG override") pos:[15, 30]
radiobuttons copy_toRB labels:#("Base color", "Base Roughness", "Base anisotropy", "Base aniso. rot", "Base IOR", "Edgecolor", "Transl. fraction", "Transl.color", "Metalness", "refraction am.",
"thin abs.color", "opacity", "Self-illumination", "Base bump", "Displacement", "Clearcoat am.", "Clearcoat IOR", "Clearcoat rough.", "Clearcoat abs.", "Clearcoat bump", "Sheen amount", "Sheen color",
"Sheen rough.", "SSS amount", "SSS radius", "SSS scatt. color", "Vol. absorption", "Vol.scattering", "Base tail", "Reflect BG override", "Refract BG override") across:2 pos:[160, 30]
groupBox group1 "copy from" pos:[10, 10] width:130 height:500
groupBox group2 "copy to" pos:[150, 10] width:130 height:500
button applycopy "Copy" pos:[50, 530] width:200 height:50
on applycopy pressed do
(
local copyfrom = copy_fromRB.state
local copyto = copy_toRB.state
local MatArr = #()
for o in selection where o.material != undefined do
join MatArr (getClassInstances CoronaPhysicalMtl target:o.material)
makeUniqueArray MatArr
for mat in MatArr do
(
local a
local b
case copyfrom of
(
1: (a = mat.baseTexmap)
2: (a = mat.baseRoughnessTexmap)
3: (a = mat.baseAnisotropyTexmap)
4: (a = mat.baseAnisoRotationTexmap)
5: (a = mat.baseIorTexmap)
6: (a = mat.edgeColorTexmap)
7: (a = mat.translucencyFractionTexmap)
8: (a = mat.translucencyColorTexmap)
9: (a = mat.metalnessTexmap)
10: (a = mat.refractionAmountTexmap)
11: (a = mat.thinAbsorptionTexmap)
12: (a = mat.opacityTexmap)
13: (a = mat.selfIllumTexmap)
14: (a = mat.baseBumpTexmap)
15: (a = mat.displacementTexmap)
16: (a = mat.clearcoatAmountTexmap)
17: (a = mat.clearcoatIorTexmap)
18: (a = mat.clearcoatRoughnessTexmap)
19: (a = mat.clearcoatAbsorptionTexmap)
20: (a = mat.clearcoatBumpTexmap)
21: (a = mat.sheenAmountTexmap)
22: (a = mat.sheenColorTexmap)
23: (a = mat.sheenRoughnessTexmap)
24: (a = mat.sssAmountTexmap)
25: (a = mat.sssRadiusTexmap)
26: (a = mat.sssScatterTexmap)
27: (a = mat.volumetricAbsorptionTexmap)
28: (a = mat.volumetricScatteringTexmap)
29: (a = mat.baseTailTexmap)
30: (a = mat.bgOverrideReflectTexmap)
31: (a = mat.bgOverrideRefractTexmap)
)
case copyto of
(
1: (b = mat.baseTexmap)
2: (b = mat.baseRoughnessTexmap)
3: (b = mat.baseAnisotropyTexmap)
4: (b = mat.baseAnisoRotationTexmap)
5: (b = mat.baseIorTexmap)
6: (b = mat.edgeColorTexmap)
7: (b = mat.translucencyFractionTexmap)
8: (b = mat.translucencyColorTexmap)
9: (b = mat.metalnessTexmap)
10: (b = mat.refractionAmountTexmap)
11: (b = mat.thinAbsorptionTexmap)
12: (b = mat.opacityTexmap)
13: (b = mat.selfIllumTexmap)
14: (b = mat.baseBumpTexmap)
15: (b = mat.displacementTexmap)
16: (b = mat.clearcoatAmountTexmap)
17: (b = mat.clearcoatIorTexmap)
18: (b = mat.clearcoatRoughnessTexmap)
19: (b = mat.clearcoatAbsorptionTexmap)
20: (b = mat.clearcoatBumpTexmap)
21: (b = mat.sheenAmountTexmap)
22: (b = mat.sheenColorTexmap)
23: (b = mat.sheenRoughnessTexmap)
24: (b = mat.sssAmountTexmap)
25: (b = mat.sssRadiusTexmap)
26: (b = mat.sssScatterTexmap)
27: (b = mat.volumetricAbsorptionTexmap)
28: (b = mat.volumetricScatteringTexmap)
29: (b = mat.baseTailTexmap)
30: (b = mat.bgOverrideReflectTexmap)
31: (b = mat.bgOverrideRefractTexmap)
)
if a != undefined do
(
b = copy a
print a
print b
)
)
MatArr = #()
)
)
createDialog progressTest 290 600
If i place the “print a” and “print b” before the “b = copy a” i 've got a different result , for a i 've got the bitmap name and for b, i’ve got" undefined" which is fine because the slot is empty and if i place the print a and print b after the "b= copy a " then a and b print the bitmap name, no more undefined but nothin appear in the material, if someone could explain what is going on it would be much appreciated