PDA

View Full Version : outputting CV attribute to file


irte
12-16-2003, 03:23 AM
im trying to output x y z attributes of a shape's CVs to a file...

Heres my script:
string $sName = `file -q -sceneName`;
$fileId = fopen($sName + ".txt","w");
fprint($fileId, $sName);
int $i;
int $j;

for($i = 0; $i < 7; $i++) {
for($j = 0; $j < 8; $j++){
print($i+" " + $j + "\n");
float $cvInf[] = getAttr("tangShape.cv[$i][$j]");
string $cv0 = $cvInf[0];
string $cv1 = $cvInf[1];
string $cv2 = $cvInf[2];
fprint($fileId, $cv0 + $cv1 + $cv2 + "\n");
}
}

fclose($fileId);

And this is the error I get:
// Error: Invalid attribute index: tangShape.cv[$i][$j] //
But if I just put integers instead of i and j, it works.
I dont understand. :( Thanks

dwalden74
12-16-2003, 02:15 PM
Your variables are inside your string(given by ""), so instead of evaluating the real value of the variable (which is what you want), it evaluates a string that actually has the $ character in it.

Just build your string and leave the $ outside the "":

getAttr("tangShape.cv[" + $i + "][" + $j + "]");

irte
12-16-2003, 04:06 PM
thanks! that makes sense (and it worked ;) -
why does getAttr take a string as a argument anyway?
That seemed funny to me.

dwalden74
12-17-2003, 02:17 PM
why does getAttr take a string as a argument anyway?

Any name in MEL is considered a string- node name, attr name, UI control name, file name - these are all strings.

CGTalk Moderation
01-16-2006, 10:00 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.