View Full Version : Python: how to create a MEL command with an array argument?

07 July 2007, 09:35 AM

I would like to create a python plugin wich create a MEL command that can accept an array as one of it's argument.
So, calling this command would look like something as this:
float $test[] = {1,2,3};
myCommand -v $test;

The command creation is ok, as well as getting the values for the different arguments.
My trouble is how to get the array in python?

I already did this with the API using MArgList.get(unsigned int& index, MDoubleArray & ret)
But this is not avalaible with python...

I'm still starting python, so any hint is welcome!

07 July 2007, 08:18 PM

I finally have a solution, thanks to autodesk support!

It uses MArgList:: asDoubleArray, but the trick is that it requires a pointer for the argument's index, wich is created using MScriptUtil.

It looks like this:

# The index of the command's argument
# This is to get a pointer to the index's value
MScript = OpenMaya.MScriptUtil()
argsIdxPtr = MScript.asUintPtr()
# Get the array argument values into dataArray
dataArray = args.asDoubleArray(argsIdxPtr)

Hope it will help someone ;)


CGTalk Moderation
07 July 2007, 08:18 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.