simple proc gives error

Become a member of the CGSociety

Connect, Share, and Learn with our Large Growing CG Art Community. It's Free!

THREAD CLOSED
 
Thread Tools Search this Thread Display Modes
Old 09 September 2005   #1
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 September 2005   #2
proc MoveToObject(string $moved, string $to)

{

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

select $moved;

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

select -cl;

}

__________________

 
Old 09 September 2005   #3
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 September 2005   #4
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 September 2005 at 03:29 PM.
 
Old 09 September 2005   #5
vector $position = `getAttr ($to + ".translate")`;

works as well,
Thanks for the info.


 
Old 09 September 2005   #6
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.
 
Thread Closed share thread



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 01:05 PM.


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