Hi, basically what I want to do is to assign material property to an array like
d_standard =#("diffuseMap")and later call it as property like
defmat = standardMaterial()
texPath = Bitmaptexture fileName:tmp
defmat.d_standard[1] = texPath << This is where I get lost
Is there any way I can achieve that with maxscript? For now my script is bloated because I have to define each slot, and I need to simplify and I already stuck in 2 days for this. Thank you and appreciate any help.
Replies
myArray = #()
Or are you specifically asking about texture paths?
myArray = #()
append myArray (meditMaterials[1].diffusemap.filename)
meditMaterials[1].specularmap.filename = myArray[1]
d_standard = #(""diffuseMap", "ambientMap", "displacementMap", "bumpMap") -- and so on
or with corona:
d_corona = #("texmapDiffuse", <diffusewithcoronaAO>, "texmapDisplacement") -- and so on
and I want to call that array value instead of material property ex:
in diffuse texture slot with standard material, i will replace myMaterial.diffuseMap with myMaterial.d_standard[1]
or, if I use corona, i will replace myMaterial.texmapDiffuse with myMaterial.d_corona[1]
Problem here is .diffuseMap (or .texmapDiffuse) is property name of that material, which will throw error if i replace with array index (.d_standard[1] in this example). Is there any workaround this?
I'm sorry if the question is not clear enough, try the best I can.
Edit: Heres the documentation for getproperty and setproperty (just search for it) https://help.autodesk.com/view/3DSMAX/2017/ENU/?guid=__files_GUID_879ECFAD_7928_44B3_BCD7_276D53C89B52_htm
@haiddasalami, thank you, it works using setProperty.
Bitmaptexture fileName:tmp cant be executed because it cant be converted to string.
execute ("defmat." + texSlot[slotIndex] + "Map=" + texpath)
-- Unable to convert: Bitmaptexture:Bitmap to type: String
When I tried to convert it,
execute ("defmat." + texSlot[slotIndex] + "Map=" + texpath as string)
-- Error occurred during fileIn in <ReadonlyTextFileStream:0x0000a0c8>; line number: 478
Thank you guys for your time.
So you wouldn't convert to the Bitmaptexture to a string. You would set it as a global variable, and then just use the variable as the string.
...but stick with setproperty, I try to avoid execute because it operate in global scope. Set property is mapped as well, so you can set many properties at once.