tokenize giving error on first run

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 04 April 2003   #1
Question tokenize giving error on first run

hi all,

i've got this bit of code to return the matrial of a selected object and then make it semi transparent. it works...apart from the first time i run it..i get this error

// Error: Invalid call to "tokenize". Check number and types of arguments expected by the procedure. //


but then if i run it straight after, it all works fine.

here is the code, try it yourself.


$sel = `ls -flatten -sl `;
$setArray = `listSets -type 1 -ets -o $sel`;
$material = `connectionInfo -sfd ($setArray[0] + ".surfaceShader")`;
string $buffer[];
tokenize $material "." $buffer;

print ($material+"\n");
print ($buffer[0]+"\n");
$selmat = $buffer[0]+".transparency";
print $selmat;
setAttr $selmat -type double3 0.5 0.5 0.5 ;

just select an object with a material assigned to it, and it should make it 50% transparent.

i cant see what is wrong with the way i have used tokenize, i have tried it several other ways also, but always get the same error. could it be somethign to do with not being inside a global procedure?
 
Old 04 April 2003   #2
the tokenize command worked fine here. Maybe check that you actually have anything in your $material string the first time you run
__________________
CaptainSam
 
Old 04 April 2003   #3
Off the top of my head, I think the problem is more likely to be with the kind of data you are feeding it. ConnectionInfo can return boolean, string and stringArray so I would check to see what's in your $material var when the script fails.

Note that in the code you posted, you did not explicitly declare $material as a string, so it can take on any datatype that connectionInfo returns, which is probably misdirecting you to think that the problem lies with the tokenize command.

-jl
 
Old 04 April 2003   #4
hey thanks for pointing me in the right direction guys, it was indeed to do with the $material string declaration

cheers
 
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.
 
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 03:21 AM.


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