2011 Software releases
Learn about the 2011 versions of some of Autodesk’s Digital Entertainment Creation tools.
  • 1/2
You are here:Forum Home / Autodesk® Maya® / MEL / Need help - working with Vectors.
  RSS 2.0 ATOM  

Need help - working with Vectors.
Rate this thread
 
34985
 
Subscribe to this thread
avatar
  • Total Posts: 5
  • Joined: 2009-09-29 00:02:28

Hi, I’m trying to write a script at the moment that uses a lot of vectors and I’ve run into a scripting issue. I need to work with vector arrays but I can’t seem to access array elements properly. For example:

This works:

vector $testb = <<1,1,1>>;
print 
($testb.x)
//Returns: 1

So does this:

vector $test[3] {<<1,1,1>>,<<2,2,2>>,<<3,3,3>>};
print 
($test[2])
//Returns: 3 3 3

However, this doesn’t:

vector $test[3] {<<1,1,1>>,<<2,2,2>>,<<3,3,3>>};
print 
($test[2].x)
// Error: print ($test[2].x) //
// Error: Line 2.17: Syntax error //

So my question is - does anyone know how to access vector array elements? How about assigning new values to an element (e.g.: $test[2].x = 4)?

Any help would be greatly appreciated. :)



Replies: 1
/img/forum/dark/default_avatar.png

humm I think it’s good thing to pass the data to another variabale

vector $test[3] = {<>,<>,<>};

vector $test2=$test[2];
print ($test2.x)
////////////////////
you can also pass it to float array or int array instade of vectors, which I prefer
float $test3[]=$test[2];
print $test3[0];

Author: salwanbadra

Replied: 08 November 2009 09:01 AM  




   
  Settings Choose Theme color: