[Closed] Scripting materials problem
macroScript Macro19
category:“DragAndDrop”
toolTip:””
(
meditMaterials[1].shaderType = 1
meditMaterials[1].name = “Checker Material”
meditMaterials[1].diffuseMap = Checker ()
meditMaterials[1][#Maps][#Diffuse_Color__Map__5____Checker].coords.U_Tiling = 10
meditMaterials[1][#Maps][#Diffuse_Color__Map__5____Checker].coords.V_Tiling = 10
meditMaterials[1][#Maps][#Diffuse_Color__Map__5____Checker].color1 = color 161 88 88
meditMaterials[1][#Maps][#Diffuse_Color__Map__5____Checker].color2 = color 86 104 167
$.material = meditMaterials[1]
)
This script is supposed to create a new material, apply a checker map to the diffuse slot, adjust its properties, U and V tiling and the colors, and apply it tho a selected object, However I get this error.
>> MAXScript MacroScript Error Exception: – Unknown property: “coords” in undefined <<
Do you know how to fix it?
Thanks
Sure! Don’t use the MacroRecorder
(na vylka mu e debel vratyt zashtoto si pishe scriptovete sam!!! ;))
macroScript CheckerMat category:"Cozmo" toolTip:"Assign Checker Material"
(
newMaterial = Standard name:"Checker Material" --define a new material
newMap = Checker() --define a new Checker map
newMap.coords.U_Tiling = 10 --set the tiling in the map
newMap.coords.V_Tiling = 10
newMap.color1 = color 161 88 88 --set the colors in the map
newMap.color2 = color 86 104 167
newMaterial.diffuseMap = newMap --assign the new map to the diffuse channel of the new material
$.material = newMaterial --assign the material to the selection
showTextureMap newMaterial newMap true --show the checker in the viewport if you want
meditmaterials[1] = newMaterial --show the material in the editor if you want
)