View Full Version : How do you pass values from a .mll to the mel script?

03 March 2006, 10:59 AM

I have written script so that the mouse can click and drag in the x,y,z directions.

I now need to use this code for another device - phantom device - though the type of device is not extremely important. I have the .mll code which can locate the x,y,z position of the phantom device but how do you pass the c++ values into the mel scipt - so that it knows that it needs to work with x,y,z values of the phantom and not the mouse?


// call the .mll for getting the x,y,z postion of the phantom device

// assign the phantom[x] to the mouse variable for [x];
// assign the phantom[y] to the mouse variable for [y];
// assign the phantom[z] to the mouse variable for [z];

03 March 2006, 11:27 AM
If I'm getting this right, you're trying to create a command plugin that will return a float array as a result?
If that's the case then you can use 'setResult'. Something like:

MFloatArray resultFloatArray;
float posX,posY,posZ;
setResult( resultFloatArray );

Hope this helps,

03 March 2006, 11:50 AM
Basically, this is the code used to return the x,y,z coordinate of the device.

hduVector3Dd position;
hdGetDoublev(HD_CURRENT_POSITION, position);

This is compiled as a .mll and called in my mel script, where position is the array of [3].

Then all I need to do is pass this c++ variable to the mel script.

Would that code work for this?

Thanks again,

03 March 2006, 12:49 PM
yup. it would.

I'd do:
MFloatArray arr(3, 0);
arr[0] = posX;
arr[1] = posY;
arr[2] = posZ;
setResult( arr );

tho ;)

03 March 2006, 01:43 PM
Thanks to the both of you who pointed me the right direction. The output int0 Maya is 0 0 0 , but I will try to figure out why.

If you have any ideas, please let me know though.

Thanks again!

CGTalk Moderation
03 March 2006, 01:43 PM
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.