CGTalk > Software > Autodesk Maya > Maya Programming
Login register
Thread Closed share thread « Previous Thread | Next Thread »  
 
Thread Tools Search this Thread Display Modes
Old 09-16-2005, 09:42 PM   #1
jgibz
Lord of the posts
 
jgibz's Avatar
portfolio
Jack Gibbons
USA
 
Join Date: Nov 2003
Posts: 787
simple proc gives error

Hi everyone, I have this proceedure that takes two objects, and moves the first to the position of the second.

proc MoveToObject(string $moved, string $to)
{
vector $positionTo = `getAttr $to.translate`;

select $moved;

move ($positionTo.x) ($positionTo.y) ($positionTo.z);

select -cl;
}

When passing two strings, each containing the name of a sphere in the scene....

MoveToObject($sphereOne, $sphereTwo);
// Error: No object matches name: .translate //

Any help would be great
 
Old 09-17-2005, 12:15 AM   #2
JFFORTIN
Bug ?!??! Again !!?!
 
JFFORTIN's Avatar
portfolio
Your full, real name.
Tech Monkey
Ubisoft
Vancouver, Canada
 
Join Date: Jun 2003
Posts: 250
proc MoveToObject(string $moved, string $to)

{

float $positionTos[] = `getAttr ($to + ".translate")`;

select $moved;

move $positionTos[0] $positionTos[1] $positionTos[2];

select -cl;

}

__________________

 
Old 09-17-2005, 05:45 PM   #3
jgibz
Lord of the posts
 
jgibz's Avatar
portfolio
Jack Gibbons
USA
 
Join Date: Nov 2003
Posts: 787
thanks JFFORTIN, Is there a bonus to using an array to store the attributes as opposed to a vector in this instance? I guess it would be better to use one array instead of 3 vectors if I were storing values for trans, rotate and scale.
 
Old 09-18-2005, 03:22 PM   #4
Segmoria
 
Segmoria's Avatar
portfolio
Eirini Stefanopoulou
Athens, Greece
 
Join Date: Feb 2002
Posts: 424
Send a message via MSN to Segmoria
I believe you can't store data to a vector using the form:
vector $positionTo = `getAttr $to.translate`
You can only use the form vector $vect = <<1, 2, 3>> but you always have to make sure you are using scalars numerics only.
Nor you can say $positionTo.x = `getAttr $to.translateX`;

Instead you have to do the following:
float $temp =
`getAttr $to.translateX`;
$positionTo.x = $temp;

As for the array advantages, when using arrays in MEL, the array subscript is being incremented as you add more data into it (thats why you don't have to define their size when declaring an array). And you can always use arrays of vectors if you wish so.

Last edited by Segmoria : 09-18-2005 at 03:29 PM.
 
Old 09-19-2005, 01:25 PM   #5
jgibz
Lord of the posts
 
jgibz's Avatar
portfolio
Jack Gibbons
USA
 
Join Date: Nov 2003
Posts: 787
vector $position = `getAttr ($to + ".translate")`;

works as well,
Thanks for the info.


 
Old 09-19-2005, 01:25 PM   #6
CGTalk Moderation
Lord of the posts
CGTalk Forum Leader
 
Join Date: Sep 2003
Posts: 1,066,481
Thread automatically closed

This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.
__________________
CGTalk Policy/Legalities
Note that as CGTalk Members, you agree to the terms and conditions of using this website.
 
Thread Closed share thread


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
CGSociety
Society of Digital Artists
www.cgsociety.org

Powered by vBulletin
Copyright 2000 - 2006,
Jelsoft Enterprises Ltd.
Minimize Ads
Forum Jump
Miscellaneous

All times are GMT. The time now is 10:06 AM.


Powered by vBulletin
Copyright ©2000 - 2016, Jelsoft Enterprises Ltd.