PDA

View Full Version : CreateMotionTrail and other undocumented commands


Mooncalf
05-31-2005, 01:11 AM
Hey y'all,

This forum has been really helpful to me in the past, so I thought I'd try my luck again. :)

I'm interested in learning just a bit more about the MEL commands that I can't seem to find in the MEL command reference in Maya.


In particular, I'm trying to make a script that will make a motion trail of a selected object, and then put that motion trail into a new layer.

I notice that when I create a motion trail manually, the command window echos "CreateMotionTrail" and "performMotionTrail" and "doMotionTrail", none of which I can seem to find any documents for. And I feel I'd need to adjust one or two flags or things to get my script to work properly.

My basic plan was to have the script do something like this:

1) Create the motion trail
2) Select the motion trail
3) Create a new layer to contain the currently selected objects


I just figure that to get from step #1 to step #2, I'll need to be able to control, or at least query, the name of the motion trail. And I simply can't figure out how to get that to happen.

Maybe I'm missing something more fundamental here. But any help would be greatly appreciated. Thanks! :)


- M

drGonzo
05-31-2005, 03:40 AM
The command you are looking for is snapshot. It has a flag called -motionTrail (-mt).
To query it, you are best casting it in a variable:
string $motionTrail []=`snapshot -mt 1`;
print $motionTrail[0];

Mooncalf
05-31-2005, 05:35 AM
Thanks Dr. Gonzo. That seems to work... but only in when things are simple. :( (here's probably where my lack of MEL knowledge shows through)

That command doesn't seem to produce an actual motion trail on the screen. The only way I can seem to get one to appear is by using this command:

doMotionTrail 1 { "snapshot -motionTrail 1 -increment 1 -constructionHistory 1 -startTime `playbackOptions -query -min` -endTime `playbackOptions -query -max`", "line", "0", "force"}


Or, using it as a variable like you mentioned:

string $NMT[] = `doMotionTrail 1 { "snapshot -motionTrail 1 -increment 1 -constructionHistory 1 -startTime `playbackOptions -query -min` -endTime `playbackOptions -query -max`", "line", "0", "force"}`;


However, when I use the command:

print $NMT[0];

I don't get the name of the motion trail, I simply get "print $NMT[0];" printed in the command window. No syntax error, but no name either.

Any hints on what am I doing wrong? Thanks! :)

- M

drGonzo
05-31-2005, 06:49 AM
Try the following.
Animate a ball over a couple of frames. Then:
//create a snap shot and name the handle whozaaa
string $mimisNickers[] =`snapshot -mt 1 -ch 1 -i 1 -name "whoozaa"`;

//print the name of the handle
print $mimisNickers[0];
//whoozaaHandle

//change the drawstyle of the handle
setAttr whoozaaHandleShape.drawStyle 1;
setAttr whoozaaHandleShape.drawStyle 2;

//show teh frames
setAttr "whoozaaHandleShape.showFrames" 1;

//if you want to select all snapshots in your scene,
//you can list them as follows

ls -type snapshotShape;

//how did i figure that out? Select the shape node (!) of the handle and type this
nodeType `ls -sl`; //magic innit?
The doMotionTrail is not a command, but a procedure that calls on several arguments. You can check which ones on the doMotionTrail.mel script in your Maya - scripts folder. It compiles the proc as follows:
// [0] $snapshotCmd: the snapshot cmd used to create the motion trail
// [1] $drawStyle: "point", "line", "locator"
// [2] $displayFrames: boolean indicating whether to draw the frame no's
// [3] $update: "onDemand","force","animCurve"
// Note: in the UI the $update variables correspond to:
// "onDemand" = on demand
// "force" = always (slow)
// "animCurve" = when animation changes (fast)


I did not invent this, its in the header of the script.


If you give me an outline of the script you are planning to write, maybe I can give it a go if I find some time.

drGonzo
05-31-2005, 08:22 AM
global proc km_addSnapShotToLayer()
{
//get selected object
string $sel[] = `ls -sl`;
//create a snap shot and name the handle whozaaa
string $mimisNickers[] =`snapshot -mt 1 -ch 1 -i 1 -name($sel[0] +"_snapShot_") `;
setAttr ($mimisNickers[0]+ ".showFrames") 1;
//put snapshot stuff in display layer
createDisplayLayer -name ($sel[0]+ "_snapShot_layer") $mimisNickers;
}

Mind you, this is very rough code. No dummy proofing, no catches.

CGTalk Moderation
05-31-2005, 08:22 AM
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.