add array to ice with jscript

Discussions concerning programming of SOFTIMAGE©
clankill3r
Posts: 131
Joined: 21 Oct 2012, 13:36

add array to ice with jscript

Post by clankill3r » 05 Nov 2012, 13:43

I have this simple script:

Code: Select all

var ForReading = 1;
var fso = new ActiveXObject("Scripting.FileSystemObject");
var fileObj = fso.GetFile("F:\\temp\\csv_reader_01.txt");
var ts = fileObj.OpenAsTextStream(ForReading, 0 );

var delimiter = ";";

while(!ts.AtEndOfStream) {
    var textLine = ts.ReadLine();
	var tokens = textLine.split(delimiter);
	for(var i = 0; i < 5; i++) {
		LogMessage(tokens[i]);
	}
}
ts.Close();


LogMessage("done");
what i want to do is add each line of the textfile as a array to a ice tree.
Or add it as a 2d array.

I tried some things like Selection.AddProperty("UserDataBlob", false, "myBlob");
But no matter what i try i can't get it done, could someone help.

Letterbox
Posts: 391
Joined: 17 Jun 2009, 12:49

Re: add array to ice with jscript

Post by Letterbox » 07 Nov 2012, 09:14

thats why luceric posted this up for you, its exactly what you need to use. find in the "node for reading files" thread

http://download.autodesk.com/global/docs/softimage2013/en_us/sdkguide/index.html?url=files/GUID-177FE97B-99EB-4EF2-A33A-B17811915954.htm,topicNumber=d30e796

you just need to change the log message to the correct method on the above page. That's of course assuming your using 2013.

clankill3r
Posts: 131
Joined: 21 Oct 2012, 13:36

Re: add array to ice with jscript

Post by clankill3r » 13 Nov 2012, 22:26

there is a post related to this on xsi support
http://xsisupport.com/2012/11/13/scripting-writing-the-dataarray-of-an-ice-attribute/

however stephen blair can't get it done in jscript and neither can i.
Would be great if one of you guys can.

User avatar
xsisupport
Posts: 713
Joined: 09 Jun 2009, 09:02
Location: Montreal Canada

Re: add array to ice with jscript

Post by xsisupport » 14 Nov 2012, 08:23

clankill3r wrote:there is a post related to this on xsi support
http://xsisupport.com/2012/11/13/scripting-writing-the-dataarray-of-an-ice-attribute/

however stephen blair can't get it done in jscript and neither can i.
Would be great if one of you guys can.
Maybe I was having an off day, but I don't think it works in JScript :-)
Create a Python command with the minimal amount of Python code needed to stuff the array into the DataArray, and the call that from your JScript, where you will do all the rest of the work.

http://xsisupport.com/2012/11/13/script ... attribute/
// Steve Blair
// "You're not a runner, you're just a guy who runs" -- my wife
//
// My Blogs: Arnold | Softimage