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 CLOSED
 
Thread Tools Search this Thread Display Modes
Old 12 December 2003   #1
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");
}
}

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
 
Old 12 December 2003   #2
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
www.davidwalden.com
 
Old 12 December 2003   #3
thanks

thanks! that makes sense (and it worked -
why does getAttr take a string as a argument anyway?
That seemed funny to me.
 
Old 12 December 2003   #4
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
www.davidwalden.com
 
Old 01 January 2006   #5
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
CGSociety
Society of Digital Artists
www.cgsociety.org

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

All times are GMT. The time now is 07:00 PM.


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