http://wp.me/powV4-2E1

On 25/03/2013 4:29 AM, Eugen Sares wrote:
Thanks, Ho Chung!
Writing to the MaterialID attribute works (array of integers), but not to Materials (array of strings). Workaround would be to create an ICE array via scripting, I got that working already, but still I wonder why the problem is.
Could you please check this code?


NewScene("", "false");
var oObj = CreatePrim("grid", "MeshSurface", "", "");
SetValue(oObj + ".polymsh.geom.subdivu", 2, null);
SetValue(oObj + ".polymsh.geom.subdivv", 2, null);

oIA = oObj.ActivePrimitive.Geometry.AddICEAttribute("CustomMaterials", siICENodeDataType.siICENodeDataString, siICENodeStructureType.siICENodeStructureArray, siICENodeContextType.siICENodeContextSingleton);
var aData = ["Mat0", "Mat1", "Mat2", "Mat3"];
//oIA.DataArray = aData; // WARNING : 3392 - Invalid offset specified
var saData = getSafeArray(aData);
oIA.DataArray = saData; // WARNING : 3392 - Invalid offset specified


function getSafeArray(jsArr)
{
    var dict = new ActiveXObject("Scripting.Dictionary");
    for(var i = 0; i < jsArr.length; i++)
    dict.add(i, jsArr[i]);
    return dict.Items();
}


Reply via email to