leach
04-27-2003, 07:23 PM
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? :shrug:
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? :shrug:
