Way_south02
Jan 31, 2011
Post id: 306978 Report Item

hi,
I'm a MEL newbie and I need to position a locator at the place where another object will be in 2-3 frames. Any Ideas?
I know this might be real simple, but I haven't been able to figure it out yet.
Thanx.

Way_south02
Jan 31, 2011
Post id: 306983 Report Item

I understand the basic principle, but how do I go about doing this?
Lets say the object I want to drive the position of the locator is pcube1 and I want Locator1 to always be at the position of pcube1 at frame+1, what's the code I need to put into the expression editor of Locator 1?
(Like I said, I'm a scripting newbie...)
Thanks for your help.

Avatar2
Jan 31, 2011
Post id: 306979 Report Item

You can modify the "getAttr" command with the -time flag to get attributes at the specified time. This however works only if the attribute itself is driven by keyframes, constraints or valid expressions, means containing no mel syntax.

Avatar2
Jan 31, 2011
Post id: 306985 Report Item

in this case it would look like

int $currentTime = frame;
// or: int $currentTime = `currentTime -q`;

float $p[] = `getAttr -time ($currentTime + 1) "pCube1.translate"`;

// now since the expression already is "downgraded" to mel you can feed the locators translate attribute in one go

setAttr "locator1.translate" $p[0] $p[1] $p[2];

// or: move $p[0] $p[1] $p[2] "locator1";
// or: xform -worldSpace -translation $p[0] $p[1] $p[2] "locator1";

Dashboard_avatar
Feb 01, 2011
Post id: 307000 Report Item

>> // now since the expression already is "downgraded" to mel you can feed the locators translate attribute in one go


No theres still one dsiadvantage to doing this over the expression syntax! And tahst that the data goes to the undo stack that can totally wreck your mayta experience. So still use expressions going out:


locator1.translateX=$p[0];
locator1.translateY=$p[1];
locator1.translateZ=$p[2];


Just because something is broken dont mean you should break things even more! And No the users will not appreciate you rigging so thay can not meaningfully undo anymore. No need to slow things down extra just so you can save 2´lines of typing especially whan its just a copypsate and its faster to run.

Avatar2
Feb 01, 2011
Post id: 307002 Report Item

Ups, i`ve missed that out ;)

Way_south02
Feb 02, 2011
Post id: 307022 Report Item

Thanks, that does the trick for me:-)
Cheers,
Chris