I am not a scripter at all. I am using softimage XSI 7.01, and all I really need it to do, is read the position and rotation information off a selected null or object on each frame and output that to a text file that looks like the image attatched.
It looks like there is 1 tab space between each parameter.
I am using this to load it back into tracking software and this is the format it uses.
Help with simple script
Re: Help with simple script
This script logs the data to the script output. There will be some //INFO like characters at the left that you would have to delete...
(script editor must be set to jscript to run this)
(script editor must be set to jscript to run this)
Code: Select all
var sel=Selection(0);
var space=" ";
var frames=20;
for(var n=1; n<frames; n++)
logmessage(n+space+
sel.kinematics.local.posx.value(n)+space+
sel.kinematics.local.posy.value(n)+space+
sel.kinematics.local.posz.value(n)+space+
sel.kinematics.local.roty.value(n)+space+
sel.kinematics.local.rotx.value(n)+space+
sel.kinematics.local.rotz.value(n)+space
);
softimage resources section updated Jan 5th 2024
Re: Help with simple script
Nice rray! I didn't know you could get a frame position with that. I always used GetValue
I modified that code to round those values to 3 decimals, and write it into a TXT file:
And a few notes:
In my modified version I separated the variables you can edit to the top, and the code to the bottom.
Be sure to run this in a JScript tab (not VBscript nor Python).
If you want global values, replace "local" with "global.
When you specify a file path, use \\ instead of \. (ex: D:\test.txt is wrong, D:\\test.txt is correct)
I modified that code to round those values to 3 decimals, and write it into a TXT file:
Code: Select all
//JScript
//------------------------------
var space = " "
var startFrame = 1
var endFrame = 20
var roundDecimals = 3
var filePath = "D:\\test.txt"
//------------------------------
var sel=Selection(0);
var fso = new ActiveXObject( "Scripting.FileSystemObject" );
var txt = fso.OpenTextFile( filePath, 2, true )
for(var n=startFrame; n<endFrame+1; n++)
txt.WriteLine( n+space+
sel.kinematics.local.posx.value(n).toFixed(roundDecimals) +space+
sel.kinematics.local.posy.value(n).toFixed(roundDecimals) +space+
sel.kinematics.local.posz.value(n).toFixed(roundDecimals) +space+
sel.kinematics.local.roty.value(n).toFixed(roundDecimals) +space+
sel.kinematics.local.rotx.value(n).toFixed(roundDecimals) +space+
sel.kinematics.local.rotz.value(n).toFixed(roundDecimals) +space
);
txt.Close();
In my modified version I separated the variables you can edit to the top, and the code to the bottom.
Be sure to run this in a JScript tab (not VBscript nor Python).
If you want global values, replace "local" with "global.
When you specify a file path, use \\ instead of \. (ex: D:\test.txt is wrong, D:\\test.txt is correct)
M.Yara
Character Modeler | Softimage Generalist (sort of)
Character Modeler | Softimage Generalist (sort of)
Re: Help with simple script
Hehe didn't know either, just discovered by accident.. thought it might be worth a try before looking up the GetValue syntax with frames.
softimage resources section updated Jan 5th 2024
Re: Help with simple script
Thank you so much, that does exactly what I needed!
Who is online
Users browsing this forum: trendiction [Bot] and 18 guests