hey guys-
I am writing a new proc, and I think I am doin everything right, but I get an error:
// Error: Cannot convert data of type string[] to type string. //
here is the code
CODE
string $selected[] = ls -sl -fl -type joint;
string $shoulder = $selected[0];
string $wrist = $selected[1];
string $elbow = listRelatives -c $shoulder;
when I run the size command on $shoulder I get 6, but I am expecting one? Any ideas.. One more question while I am here. If I call CODE
listRelatives -c $shoulder
and there is only one direct child shouldn't I get a string and not a string array? Or does it include grandchildren ect. I thought that was the function of the -allDescendants flag.
Thanks for your help.
Scott
ok.... so its wierd to post to my own topic, but I found my silly mistake, but I am unsure how to correct it. When I declared the $shoulder variable it designated each letter as its own string, that's why I am getting a string array, (joint2 = size 6 aka 6 letters) How can avoid or resolve this issue?
Thanks
Scott
No, you'll always get array because that's the data type the command returns. If there's only one children an array with only one element will be returned.
well failure-
i called size on the first variable and got 2 as I expected, but when sizing the second variable I get 6. This shows two different behavors, maybe that's why I am confused.
ie
with two bones selected
CODE
string $selected[] = ls -sl -fl -type joint;
size $selected;
//result 2;
string $shldr = $selected[0];
size $shldr;
//result 6;
the first counts the elements in the array (ie. joints), and the second counts letters in strings..... is that normal?
thanks
Scott
just assign element 0 of the array to a regular string variable
CODE
string $selected[] = ls -sl -fl -type joint;
string $shoulder = $selected[0];
string $wrist = $selected[1];
string $children[] = listRelatives -c $shoulder;
string $elbow = $children[ 0 ];
So string array is just a collection of regular string variables. Each element of array that is acessible by [] notation is in fact a simple string.
QUOTE(sheriffcicada @ 01/04/06, 12:57 AM)
the first counts the elements in the array (ie. joints), and the second counts letters in strings..... is that normal?
Yes. As far as size command is concerned a simple string is just an array of characters. But don't get confused - in most other cases you can't treat a string as an array (including bracket syntax for accessing individual characters)
Thank you failure-
I should have known this, and I thought I had tried it, but it works fine now. you are the man!!
I'll post the workin script once I get it done.
Scott
RTFM! 
The maya docs say it loud and clear:
This command returns the number of elements in an array or the number of characters in a string.