outputting CV attribute to file

Become a member of the CGSociety

Connect, Share, and Learn with our Large Growing CG Art Community. It's Free!

Thread Tools Display Modes
  12 December 2003
Question outputting CV attribute to file

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");


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
  12 December 2003
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 + "]");
David Walden
Rigging | MEL Scripting | Animation
  12 December 2003

thanks! that makes sense (and it worked -
why does getAttr take a string as a argument anyway?
That seemed funny to me.
  12 December 2003
Quote: 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.
David Walden
Rigging | MEL Scripting | Animation
  01 January 2006
Thread automatically closed

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.
CGTalk Policy/Legalities
Note that as CGTalk Members, you agree to the terms and conditions of using this website.
Thread Closed share thread

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Society of Digital Artists

Powered by vBulletin
Copyright 2000 - 2006,
Jelsoft Enterprises Ltd.
Minimize Ads
Forum Jump

All times are GMT. The time now is 01:25 PM.

Powered by vBulletin
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.