Call for Submission
NAB 2012 Best of the Best Show Reel
Submit your work today!
  • 1/3
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
 
Permlink of this thread   Subscribe to this thread
avatar
  • Total Posts: 7
  • Joined: 28 September 2009 08:02 PM

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] = {<<1,1,1>>,<<2,2,2>>,<<3,3,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 01:01 AM  




   
  Settings Choose Theme color: