srafx
11-20-2008, 01:31 PM
I used a sample script and modified it. I sware at one point that this code actually opened a dialog so I can select the data file. Currently when I run this code nothing happens. I even tried to set the strings to the specific data file and objectname.
global proc getAnim(string $fileName, string $objectName)
{
//open the file DADs data file
$fileId=`fopen $fileName "r"`;
//read line one
string $nextLine = `fgetline $fileId`;
//Looks for end
while ( size( $nextLine ) > 0 ) {
//split line into separate elements
string $rawAnimArray[];
tokenize ($nextLine, " ",$rawAnimArray);
//place each element of the array into separate variables
print $rawAnimArray;
float $frame=$rawAnimArray[0];
float $tx=$rawAnimArray[1];
float $ty=$rawAnimArray[2];
float $tz=$rawAnimArray[3];
float $rx=$rawAnimArray[4];
float $ry=$rawAnimArray[5];
float $rz=$rawAnimArray[6];
//change the currentTime
currentTime $frame ;
//sets objects translation x,y,z
setAttr ($objectName+".tx") $tx;
setKeyframe ($objectName+".tx");
setAttr ($objectName+".ty") $ty;
setKeyframe ($objectName+".ty");
setAttr ($objectName+".tz") $tz;
setKeyframe ($objectName+".tz");
//sets objects rotation x,y,z
setAttr ($objectName+".rx") $rx;
setKeyframe ($objectName+".rx");
setAttr ($objectName+".ry") $ry;
setKeyframe ($objectName+".ry");
setAttr ($objectName+".rz") $rz;
setKeyframe ($objectName+".rz");
//next line and loop
$nextLine = `fgetline $fileId`;
}
//close file
fclose $fileId;
}
This is the data I am trying to import (t,x,y,z,h,p,r)
0.00000000 0.00000000 0.00000000 0.00000000 -0.00000000 0.00000000 -0.00000000
0.05000000 0.00000000 0.25000000 0.00000000 -0.00000000 0.00000000 -0.00000000
0.10000000 0.00000000 0.49999999 0.00000000 -0.00000000 0.00000000 -0.00000000
0.15000001 0.00000000 0.75000001 0.00000000 -0.00000000 0.00000000 -0.00000000
0.20000000 0.00000000 0.99999999 0.00000000 -0.00000000 0.00000000 -0.00000000
0.25000000 0.00000000 1.25000004 0.00000000 -0.00000000 0.00000000 -0.00000000
0.30000001 0.00000000 1.50000002 0.00000000 -0.00000000 0.00000000 -0.00000000
0.34999999 0.00000000 1.75000000 0.00000000 -0.00000000 0.00000000 -0.00000000
0.40000001 0.00000000 1.99999998 0.00000000 -0.00000000 0.00000000 -0.00000000
0.44999999 0.00000000 2.24999995 0.00000000 -0.00000000 0.00000000 -0.00000000
0.50000000 0.00000000 2.50000008 0.00000000 -0.00000000 0.00000000 -0.00000000
0.55000001 0.00000000 2.74999991 0.00000000 -0.00000000 0.00000000 -0.00000000
0.60000002 0.00000000 3.00000004 0.00000000 -0.00000000 0.00000000 -0.00000000
0.64999998 0.00000000 3.24999987 0.00000000 -0.00000000 0.00000000 -0.00000000
0.69999999 0.00000000 3.49999999 0.00000000 -0.00000000 0.00000000 -0.00000000
0.75000000 0.00000000 3.75000012 0.00000000 -0.00000000 0.00000000 -0.00000000
0.80000001 0.00000000 3.99999995 0.00000000 -0.00000000 0.00000000 -0.00000000
0.85000002 0.00000000 4.25000008 0.00000000 -0.00000000 0.00000000 -0.00000000
0.89999998 0.00000000 4.49999991 0.00000000 -0.00000000 0.00000000 -0.00000000
0.94999999 0.00000000 4.75000003 0.00000000 -0.00000000 0.00000000 -0.00000000
1.00000000 0.00000000 5.00000016 0.00000000 -0.00000000 0.00000000 -0.00000000
1.04999995 0.00000000 5.24999999 0.00000000 -0.00000000 0.00000000 -0.00000000
1.10000002 0.00000000 5.49999982 0.00000000 -0.00000000 0.00000000 -0.00000000
1.14999998 0.00000000 5.75000024 0.00000000 -0.00000000 0.00000000 -0.00000000
1.20000005 0.00000000 6.00000007 0.00000000 -0.00000000 0.00000000 -0.00000000
1.25000000 0.00000000 6.24999991 0.00000000 -0.00000000 0.00000000 -0.00000000
1.29999995 0.00000000 6.49999974 0.00000000 -0.00000000 0.00000000 -0.00000000
1.35000002 0.00000000 6.75000016 0.00000000 -0.00000000 0.00000000 -0.00000000
1.39999998 0.00000000 6.99999999 0.00000000 -0.00000000 0.00000000 -0.00000000
1.45000005 0.00000000 7.24999982 0.00000000 -0.00000000 0.00000000 -0.00000000
1.50000000 0.00000000 7.50000024 0.00000000 -0.00000000 0.00000000 -0.00000000
Any help would be appreciated!
Thanks in advance.
Steve
global proc getAnim(string $fileName, string $objectName)
{
//open the file DADs data file
$fileId=`fopen $fileName "r"`;
//read line one
string $nextLine = `fgetline $fileId`;
//Looks for end
while ( size( $nextLine ) > 0 ) {
//split line into separate elements
string $rawAnimArray[];
tokenize ($nextLine, " ",$rawAnimArray);
//place each element of the array into separate variables
print $rawAnimArray;
float $frame=$rawAnimArray[0];
float $tx=$rawAnimArray[1];
float $ty=$rawAnimArray[2];
float $tz=$rawAnimArray[3];
float $rx=$rawAnimArray[4];
float $ry=$rawAnimArray[5];
float $rz=$rawAnimArray[6];
//change the currentTime
currentTime $frame ;
//sets objects translation x,y,z
setAttr ($objectName+".tx") $tx;
setKeyframe ($objectName+".tx");
setAttr ($objectName+".ty") $ty;
setKeyframe ($objectName+".ty");
setAttr ($objectName+".tz") $tz;
setKeyframe ($objectName+".tz");
//sets objects rotation x,y,z
setAttr ($objectName+".rx") $rx;
setKeyframe ($objectName+".rx");
setAttr ($objectName+".ry") $ry;
setKeyframe ($objectName+".ry");
setAttr ($objectName+".rz") $rz;
setKeyframe ($objectName+".rz");
//next line and loop
$nextLine = `fgetline $fileId`;
}
//close file
fclose $fileId;
}
This is the data I am trying to import (t,x,y,z,h,p,r)
0.00000000 0.00000000 0.00000000 0.00000000 -0.00000000 0.00000000 -0.00000000
0.05000000 0.00000000 0.25000000 0.00000000 -0.00000000 0.00000000 -0.00000000
0.10000000 0.00000000 0.49999999 0.00000000 -0.00000000 0.00000000 -0.00000000
0.15000001 0.00000000 0.75000001 0.00000000 -0.00000000 0.00000000 -0.00000000
0.20000000 0.00000000 0.99999999 0.00000000 -0.00000000 0.00000000 -0.00000000
0.25000000 0.00000000 1.25000004 0.00000000 -0.00000000 0.00000000 -0.00000000
0.30000001 0.00000000 1.50000002 0.00000000 -0.00000000 0.00000000 -0.00000000
0.34999999 0.00000000 1.75000000 0.00000000 -0.00000000 0.00000000 -0.00000000
0.40000001 0.00000000 1.99999998 0.00000000 -0.00000000 0.00000000 -0.00000000
0.44999999 0.00000000 2.24999995 0.00000000 -0.00000000 0.00000000 -0.00000000
0.50000000 0.00000000 2.50000008 0.00000000 -0.00000000 0.00000000 -0.00000000
0.55000001 0.00000000 2.74999991 0.00000000 -0.00000000 0.00000000 -0.00000000
0.60000002 0.00000000 3.00000004 0.00000000 -0.00000000 0.00000000 -0.00000000
0.64999998 0.00000000 3.24999987 0.00000000 -0.00000000 0.00000000 -0.00000000
0.69999999 0.00000000 3.49999999 0.00000000 -0.00000000 0.00000000 -0.00000000
0.75000000 0.00000000 3.75000012 0.00000000 -0.00000000 0.00000000 -0.00000000
0.80000001 0.00000000 3.99999995 0.00000000 -0.00000000 0.00000000 -0.00000000
0.85000002 0.00000000 4.25000008 0.00000000 -0.00000000 0.00000000 -0.00000000
0.89999998 0.00000000 4.49999991 0.00000000 -0.00000000 0.00000000 -0.00000000
0.94999999 0.00000000 4.75000003 0.00000000 -0.00000000 0.00000000 -0.00000000
1.00000000 0.00000000 5.00000016 0.00000000 -0.00000000 0.00000000 -0.00000000
1.04999995 0.00000000 5.24999999 0.00000000 -0.00000000 0.00000000 -0.00000000
1.10000002 0.00000000 5.49999982 0.00000000 -0.00000000 0.00000000 -0.00000000
1.14999998 0.00000000 5.75000024 0.00000000 -0.00000000 0.00000000 -0.00000000
1.20000005 0.00000000 6.00000007 0.00000000 -0.00000000 0.00000000 -0.00000000
1.25000000 0.00000000 6.24999991 0.00000000 -0.00000000 0.00000000 -0.00000000
1.29999995 0.00000000 6.49999974 0.00000000 -0.00000000 0.00000000 -0.00000000
1.35000002 0.00000000 6.75000016 0.00000000 -0.00000000 0.00000000 -0.00000000
1.39999998 0.00000000 6.99999999 0.00000000 -0.00000000 0.00000000 -0.00000000
1.45000005 0.00000000 7.24999982 0.00000000 -0.00000000 0.00000000 -0.00000000
1.50000000 0.00000000 7.50000024 0.00000000 -0.00000000 0.00000000 -0.00000000
Any help would be appreciated!
Thanks in advance.
Steve
