Aha! Setting DataArray2D with JScript

It came to me this morning while I was lying in the dentist chair.
I almost had it last Thursday.
Hat tip: Ho Chung

//var o = Selection(0)
//var oICEAttrMats = o.ActivePrimitive.AddICEAttribute("MyString", siICENodeDataString, siICENodeStructureArray, siICENodeContextSingleton);

var o = Selection(0);
var a = o.ActivePrimitive.ICEAttributes("MyString");

sa = getSafeArray( [ "a", "b", "c" ] );
//jsa = new VBArray( sa ).toArray();

sa1 = getSafeArray( [sa] );

a.DataArray2D = sa1;

// Get a safearray from a JScript array
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();

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s