Home Coding, Scripting, Shaders

(MEL) getting selected vtx index ?

polycounter lvl 16
Offline / Send Message
onionhead_o polycounter lvl 16

{<br> string $compSel[]= `ls -sl -fl`;<br> string $obj[]= `ls -hilite -type "transform"`;<br> string $storeEdgeLoop[];<br> int $numTokens;<br> string $buffer[];<br> int $id[];<br> for($comp in $compSel){<br> $numTokens = `tokenize $comp ".[]" $buffer`;<br> //print ($buffer[2] + "\n");<br> $id[size($id)] = int($buffer[2]);<br> print $id[size($id)];<br> }<br>}<br>

With this code I should be able to store the value as int in $id[] array. But for some reason int($buffer[2]) gives me 0;


Replies

  • haiddasalami
    Offline / Send Message
    haiddasalami polycounter lvl 14
    Wouldnt size($id) give you +1 for your array. You probably need to subtract 1 since arrays are 0 index'd. Doing print ($id[size($id)-1] + "\n"); outputs the correct numbers from a quick test. 
  • onionhead_o
    Offline / Send Message
    onionhead_o polycounter lvl 16
    thanks haiddasalami. I ended up with this code for those who might be interested.

           string $compSel[]= `ls -sl -fl`;
          int $numTokens;
          string $buffer[];
          int $x;
           int $id[];
           for($comp in $compSel)
           {
          $numTokens = `tokenize $comp "[:]" $buffer`;
          //print ($buffer[1] + "\n");
          $id[$x] = int($buffer[1]);
          //print ($id[$x] + "\n");
          $x++;
           }    


Sign In or Register to comment.