MScriptUtil Class Reference

#include <MScriptUtil.h>

Class Description

Utility class for working with pointers and references in Python.

Many of Maya's API methods require that one or more of their parameters be passed as pointers or references. Their return values, too, can be pointers or references.

In Python parameters of class types are passed by reference but parameters of simple types, like integers and floats, are passed by value, making it impossible to call those API methods from Python. The MScriptUtil class bridges this gap by providing methods which return pointers to values of simple types and which can extract values from such pointers. These pointers can also be used wherever an API method requires a reference to a simple type or an array of a simple type.

For example, MTransformationMatrix::setShear() requires as its first parameter an array of three values of simple type 'double'. To call setShear() from Python requires using MScriptUtil to create the array of doubles:

matrix = maya.OpenMaya.MTransformationMatrix()
util = maya.OpenMaya.MScriptUtil()
util.createFromDouble(1.0, 2.0, 3.0)
ptr = util.asDoublePtr()
m.setShear(ptr, maya.OpenMaya.MSpace.kObject)

Similar code is required to get the shear value using MTransformationMatrix::getShear(), but MScriptUtil methods must also be used to extract the returned values from the array:

util = maya.OpenMaya.MScriptUtil()
util.createFromDouble(0.0, 0.0, 0.0)
ptr = util.asDoublePtr()
matrix.getShear(ptr, maya.OpenMaya.MSpace.kObject)
shearX = util.getDoubleArrayItem(ptr, 0)
shearY = util.getDoubleArrayItem(ptr, 1)
shearZ = util.getDoubleArrayItem(ptr, 2)

If a method requires a reference or pointer to an enumerated value, use a pointer to a short int instead.

An MScriptUtil object keeps two sets of values internally: its initial values, and its working values. The initial values are those supplied either in the constructor or by calling one of the object's create*() methods. The working values are those to which the as*Ptr() methods return pointers.

Each time a create*() method is called it completely replaces the old initial values with the new ones. The as*() methods (asInt(), asFloat(), etc) but not the as*Ptr() methods, all return the first internal value, converted to the appropriate type.

Each time an as*Ptr() method is called it completely replaces the old working values with new ones of the requested type and initializes them from the initial values. If the type of the working values does not match that of the initial values then appropriate conversions are done. For example, if you have initialized an MScriptUtil object with four doubles via a call to createFromDouble(), then a subsequent call to asBoolPtr() will allocate space for four boolean working values and initialize them from the initial values by converting non-zero values to true and zero values to false.

The separation of initial and working values means that changes to the working values will not affect the initial values. For example, if you pass the pointer returned by asBoolPtr() to an API method which changes the working value it points to, the object's initial value will remain unchanged and its asInt() method will continue to return the same value as it did before the API call.

The number of working values returned by the as*Ptr() methods will match the number of initial values. Thus it is important that you provide a sufficient number of initial values before calling an as*Ptr() method. If no initial values are provided in the MScriptUtil constructor and none are subsequently supplied by calls to the create*() methods, then the pointers returned by the as*Ptr() methods won't have room to store even a single value, which will likely lead to errors.

As already noted, each call to one of an object's as*Ptr() methods completely replaces the old working values with new ones, thus rendering invalid any pointers previously returned by that object. This means that if you need multiple pointers for a single API call, you will need multiple MScriptUtil objects. MFnMesh::getUV() provides an example of this:

meshFn = maya.OpenMaya.MFnMesh(node)
u_util = maya.OpenMaya.MScriptUtil(0.0)
u_ptr = u_util.asFloatPtr()
v_util = maya.OpenMaya.MScriptUtil(0.0)
v_ptr = v_util.asFloatPtr()
meshFn.getUV(0, u_ptr, v_ptr)
u = u_util.getFloat(u_ptr)
v = v_util.getFloat(v_ptr)

When an MScriptUtil object is destroyed any pointers to its data immediately become invalid. Thus the following code will fail because the MScriptUtil objects created by getUVPtrs() will go out of scope and be destroyed when the function returns, rendering the pointers it returns invalid:

# WRONG!
def getUVPtrs():
u_util = maya.OpenMaya.MScriptUtil(0.0)
u_ptr = u_util.asFloatPtr()
v_util = maya.OpenMaya.MScriptUtil(0.0)
v_ptr = v_util.asFloatPtr()
return [u_ptr, v_ptr]
uvPtrs = getUVPtrs()
meshFn.getUV(0, uvPtrs[0], uvPtrs[1])

To work, getUVPtrs() would have to preserve the MScriptUtil objects in some way, such as passing them back to the caller as well:

# RIGHT!
def getUVPtrs():
u_util = maya.OpenMaya.MScriptUtil(0.0)
u_ptr = u_util.asFloatPtr()
v_util = maya.OpenMaya.MScriptUtil(0.0)
v_ptr = v_util.asFloatPtr()
return [(u_ptr, u_util), (v_ptr, v_util)]
uvPtrs = getUVPtrs()
meshFn.getUV(0, uvPtrs[0][0], uvPtrs[1][0])

This class is admittedly cumbersome to use but it provides a way of building parameters and accessing return values for methods which would not otherwise be accessible from Python.

Public Member Functions

 MScriptUtil ()
 Default constructor. More...
 
 ~MScriptUtil ()
 Destructor.
 
 MScriptUtil (int value)
 Instantiate class with an int value. More...
 
 MScriptUtil (short value)
 Instantiate class with an short value. More...
 
 MScriptUtil (float value)
 Instantiate class with a float value. More...
 
 MScriptUtil (double value)
 Instantiate class with an double value. More...
 
 MScriptUtil (unsigned int value)
 Instantiate class with an unsigned int value. More...
 
 MScriptUtil (bool value)
 Instantiate class with an bool value. More...
 
 MScriptUtil (const int *value)
 Instantiate class with the int value pointed to by the argument. More...
 
 MScriptUtil (const short *value)
 Instantiate class with the short value pointed to by the argument. More...
 
 MScriptUtil (const float *value)
 Instantiate class with the float value pointed to by the argument. More...
 
 MScriptUtil (const double *value)
 Instantiate class with the double value pointed to by the argument. More...
 
 MScriptUtil (const unsigned int *value)
 Instantiate class with the unsigned int value pointed to by the argument. More...
 
 MScriptUtil (const bool *value)
 Instantiate class with the bool value pointed to by the argument. More...
 
 MScriptUtil (const MIntArray &array)
 Instantiate class with an integer array. More...
 
 MScriptUtil (const MDoubleArray &array)
 Instantiate class with an double array. More...
 
 MScriptUtil (const MUintArray &array)
 Instantiate class with an unsigned integer array. More...
 
 MScriptUtil (const MUint64Array &array)
 Instantiate class with an unsigned integer array. More...
 
void createFromInt (int x, int y=0, int z=0, int w=0)
 Create this object from 4 integers. More...
 
void createFromDouble (double x, double y=0, double z=0, double w=0)
 Create this object from 4 doubles. More...
 
bool createFromList (void *pythonList, unsigned int length)
 Create this object with a python list and length. More...
 
int asInt ()
 Return the first item added to this object as an integer.
 
short asShort ()
 Return the first item added to this object as a short.
 
float asFloat ()
 Return the first item added to this object as a float.
 
double asDouble ()
 Return the first item added to this object as a double.
 
unsigned int asUint ()
 Return the first item added to this object as a unsigned integer.
 
bool asBool ()
 Return the first item added to this object as a bool.
 
int * asIntPtr ()
 Return an integer pointer to the data of this class. More...
 
short * asShortPtr ()
 Return a short pointer to the data of this class. More...
 
unsigned short * asUshortPtr ()
 Return an unsigned short pointer to the data of this class. More...
 
float * asFloatPtr ()
 Return a float pointer to the data of this class. More...
 
double * asDoublePtr ()
 Return a double pointer to the data of this class. More...
 
unsigned int * asUintPtr ()
 Return an unsigned integer pointer to the data of this class. More...
 
bool * asBoolPtr ()
 Return a bool pointer to the data of this class. More...
 
char * asCharPtr ()
 Return a char pointer to the data of this class. More...
 
unsigned char * asUcharPtr ()
 Return a unsigned char pointer to the data of this class. More...
 
Mint2 * asInt2Ptr ()
 Copy the data to a temporary array of the right type and return its address. More...
 
Mint3 * asInt3Ptr ()
 Copy the data to a temporary array of the right type and return its address. More...
 
Mint4 * asInt4Ptr ()
 Copy the data to a temporary array of the right type and return its address. More...
 
Mshort2 * asShort2Ptr ()
 Copy the data to a temporary array of the right type and return its address. More...
 
Mshort3 * asShort3Ptr ()
 Copy the data to a temporary array of the right type and return its address. More...
 
Mshort4 * asShort4Ptr ()
 Copy the data to a temporary array of the right type and return its address. More...
 
Mfloat2 * asFloat2Ptr ()
 Copy the data to a temporary array of the right type and return its address. More...
 
Mfloat3 * asFloat3Ptr ()
 Copy the data to a temporary array of the right type and return its address. More...
 
Mfloat4 * asFloat4Ptr ()
 Copy the data to a temporary array of the right type and return its address. More...
 
Mdouble2 * asDouble2Ptr ()
 Copy the data to a temporary array of the right type and return its address. More...
 
Mdouble3 * asDouble3Ptr ()
 Copy the data to a temporary array of the right type and return its address. More...
 
Mdouble4 * asDouble4Ptr ()
 Copy the data to a temporary array of the right type and return its address. More...
 
Muint2 * asUint2Ptr ()
 Copy the data to a temporary array of the right type and return its address. More...
 
Muint3 * asUint3Ptr ()
 Copy the data to a temporary array of the right type and return its address. More...
 
Muint4 * asUint4Ptr ()
 Copy the data to a temporary array of the right type and return its address. More...
 

Static Public Member Functions

static void setInt (int &var, int value)
 Set an integer reference value. More...
 
static void setShort (short &var, int value)
 Set a short reference value. More...
 
static void setFloat (float &var, double value)
 Set a float reference value. More...
 
static void setDouble (double &var, double value)
 Set a double reference value. More...
 
static void setUint (unsigned int &var, int value)
 Set an unsigned integer reference value. More...
 
static void setBool (bool &var, int value)
 Set a bool reference value. More...
 
static void setChar (char &var, int value)
 Set a char reference value. More...
 
static void setUchar (unsigned char &var, int value)
 Set an unsigned char reference value. More...
 
static int getInt (int &var)
 Get the value of an integer reference. More...
 
static int getShort (short &var)
 Get the value of a short reference. More...
 
static double getFloat (float &var)
 Get the values of a float reference. More...
 
static double getDouble (double &var)
 Get the value of a double reference. More...
 
static int getUint (unsigned int &var)
 Get the value of an unsigned int reference. More...
 
static int getBool (bool &var)
 Get the value of a bool reference. More...
 
static int getChar (char &var)
 Get the value of a char reference. More...
 
static int getUchar (unsigned char &var)
 Get the value of an unsigned char reference. More...
 
static bool setIntArray (int *var, unsigned int index, int value)
 Set an integer value in an array. More...
 
static bool setShortArray (short *var, unsigned int index, int value)
 Set a short value in an array. More...
 
static bool setFloatArray (float *var, unsigned int index, double value)
 Set a float value in an array. More...
 
static bool setDoubleArray (double *var, unsigned int index, double value)
 Set a double value in an array. More...
 
static bool setUintArray (unsigned int *var, unsigned int index, int value)
 Set an unsigned integer value in an array. More...
 
static bool setUshortArray (unsigned short *var, unsigned int index, int value)
 Set an unsigned short value in an array. More...
 
static bool setBoolArray (bool *var, unsigned int index, int value)
 Set a bool value in an array. More...
 
static bool setCharArray (char *var, unsigned int index, int value)
 Set a char value in an array. More...
 
static bool setUcharArray (unsigned char *var, unsigned int index, int value)
 Set an unsigned char value in an array. More...
 
static int getIntArrayItem (int *var, unsigned int index)
 Get a int value from an array. More...
 
static int getShortArrayItem (short *var, unsigned int index)
 Get a short value from an array. More...
 
static double getFloatArrayItem (float *var, unsigned int index)
 Get a float value from an array. More...
 
static double getDoubleArrayItem (double *var, unsigned int index)
 Get a double value from an array. More...
 
static int getUintArrayItem (unsigned int *var, unsigned int index)
 Get an unsigned value from an array. More...
 
static int getUshortArrayItem (unsigned short *var, unsigned int index)
 Get an unsigned short value from an array. More...
 
static int getBoolArrayItem (bool *var, unsigned int index)
 Get a bool value from an array. More...
 
static int getCharArrayItem (char *var, unsigned int index)
 Get a char value from an array. More...
 
static int getUcharArrayItem (unsigned char *var, unsigned int index)
 Get an unsigned char value from an array. More...
 
static bool createMatrixFromList (void *pythonList, MMatrix &matrix)
 Create an MMatrix object from a list of 16 doubles. More...
 
static bool createFloatMatrixFromList (void *pythonList, MFloatMatrix &matrix)
 Create an MFloatMatrix object from a list of 16 doubles. More...
 
static bool createIntArrayFromList (void *pythonList, MIntArray &array)
 Create an MIntArray object from a python list. More...
 
static bool createFloatArrayFromList (void *pythonList, MFloatArray &array)
 Create an MFloatArray object from a python list. More...
 
static int getInt2ArrayItem (int(*var)[2], unsigned int r, unsigned int c)
 Get a value from the two dimensional array. More...
 
static bool setInt2ArrayItem (int(*var)[2], unsigned int r, unsigned int c, int value)
 Set a value in the two dimensional array. More...
 
static int getInt3ArrayItem (int(*var)[3], unsigned int r, unsigned int c)
 Get a value from the three dimensional array. More...
 
static bool setInt3ArrayItem (int(*var)[3], unsigned int r, unsigned int c, int value)
 Set a value in the three dimensional array. More...
 
static int getInt4ArrayItem (int(*var)[4], unsigned int r, unsigned int c)
 Get a value from the four dimensional array. More...
 
static bool setInt4ArrayItem (int(*var)[4], unsigned int r, unsigned int c, int value)
 Set a value in the four dimensional array. More...
 
static short getShort2ArrayItem (short(*var)[2], unsigned int r, unsigned int c)
 Get a value from the two dimensional array. More...
 
static bool setShort2ArrayItem (short(*var)[2], unsigned int r, unsigned int c, short value)
 Set a value in the two dimensional array. More...
 
static short getShort3ArrayItem (short(*var)[3], unsigned int r, unsigned int c)
 Get a value from the three dimensional array. More...
 
static bool setShort3ArrayItem (short(*var)[3], unsigned int r, unsigned int c, short value)
 Set a value in the three dimensional array. More...
 
static short getShort4ArrayItem (short(*var)[4], unsigned int r, unsigned int c)
 Get a value from the four dimensional array. More...
 
static bool setShort4ArrayItem (short(*var)[4], unsigned int r, unsigned int c, short value)
 Set a value in the two dimensional array. More...
 
static float getFloat2ArrayItem (float(*var)[2], unsigned int r, unsigned int c)
 Get a value from the two dimensional array. More...
 
static bool setFloat2ArrayItem (float(*var)[2], unsigned int r, unsigned int c, float value)
 Set a value in the two dimensional array. More...
 
static float getFloat3ArrayItem (float(*var)[3], unsigned int r, unsigned int c)
 Get a value from the three dimensional array. More...
 
static bool setFloat3ArrayItem (float(*var)[3], unsigned int r, unsigned int c, float value)
 Set a value in the three dimensional array. More...
 
static float getFloat4ArrayItem (float(*var)[4], unsigned int r, unsigned int c)
 Get a value from the four dimensional array. More...
 
static bool setFloat4ArrayItem (float(*var)[4], unsigned int r, unsigned int c, float value)
 Set a value in the four dimensional array. More...
 
static double getDouble2ArrayItem (double(*var)[2], unsigned int r, unsigned int c)
 Get a value from the two dimensional array. More...
 
static bool setDouble2ArrayItem (double(*var)[2], unsigned int r, unsigned int c, double value)
 Set a value in the two dimensional array. More...
 
static double getDouble3ArrayItem (double(*var)[3], unsigned int r, unsigned int c)
 Get a value from the three dimensional array. More...
 
static bool setDouble3ArrayItem (double(*var)[3], unsigned int r, unsigned int c, double value)
 Set a value in the three dimensional array. More...
 
static double getDouble4ArrayItem (double(*var)[4], unsigned int r, unsigned int c)
 Get a value from the four dimensional array. More...
 
static bool setDouble4ArrayItem (double(*var)[4], unsigned int r, unsigned int c, double value)
 Set a value in the four dimensional array. More...
 
static unsigned int getUint2ArrayItem (unsigned int(*var)[2], unsigned int r, unsigned int c)
 Get a value from the two dimensional array. More...
 
static bool setUint2ArrayItem (unsigned int(*var)[2], unsigned int r, unsigned int c, unsigned int value)
 Set a value in the two dimensional array. More...
 
static unsigned int getUint3ArrayItem (unsigned int(*var)[3], unsigned int r, unsigned int c)
 Get a value from the three dimensional array. More...
 
static bool setUint3ArrayItem (unsigned int(*var)[3], unsigned int r, unsigned int c, unsigned int value)
 Set a value in the three dimensional array. More...
 
static unsigned int getUint4ArrayItem (unsigned int(*var)[4], unsigned int r, unsigned int c)
 Get a value from the four dimensional array. More...
 
static bool setUint4ArrayItem (unsigned int(*var)[4], unsigned int r, unsigned int c, unsigned int value)
 Set a value in the four dimensional array. More...
 

Constructor & Destructor Documentation

OPENMAYA_MAJOR_NAMESPACE_OPEN MScriptUtil ( )

Default constructor.

The instance is set to contain no elements.

MScriptUtil ( int  value)

Instantiate class with an int value.

Parameters
[in]valueValue to set
MScriptUtil ( short  value)

Instantiate class with an short value.

Parameters
[in]valueValue to set
MScriptUtil ( float  value)

Instantiate class with a float value.

Parameters
[in]valueValue to set
MScriptUtil ( double  value)

Instantiate class with an double value.

Parameters
[in]valueValue to set
MScriptUtil ( unsigned int  value)

Instantiate class with an unsigned int value.

Parameters
[in]valueValue to set
MScriptUtil ( bool  value)

Instantiate class with an bool value.

Parameters
[in]valueValue to set
MScriptUtil ( const int *  value)

Instantiate class with the int value pointed to by the argument.

Parameters
[in]valuePointer to value to set
MScriptUtil ( const short *  value)

Instantiate class with the short value pointed to by the argument.

Parameters
[in]valuePointer to value to set
MScriptUtil ( const float *  value)

Instantiate class with the float value pointed to by the argument.

Parameters
[in]valuePointer to value to set
MScriptUtil ( const double *  value)

Instantiate class with the double value pointed to by the argument.

Parameters
[in]valuePointer to value to set
MScriptUtil ( const unsigned int *  value)

Instantiate class with the unsigned int value pointed to by the argument.

Parameters
[in]valuePointer to value to set
MScriptUtil ( const bool *  value)

Instantiate class with the bool value pointed to by the argument.

Parameters
[in]valuePointer to value to set
MScriptUtil ( const MIntArray array)

Instantiate class with an integer array.

Parameters
[in]arrayReference to the array.
MScriptUtil ( const MDoubleArray array)

Instantiate class with an double array.

Parameters
[in]arrayReference to the array.
MScriptUtil ( const MUintArray array)

Instantiate class with an unsigned integer array.

Parameters
[in]arrayReference to the array.
MScriptUtil ( const MUint64Array array)

Instantiate class with an unsigned integer array.

Parameters
[in]arrayReference to the array.

Member Function Documentation

void createFromInt ( int  x,
int  y = 0,
int  z = 0,
int  w = 0 
)

Create this object from 4 integers.

Data already stored in this class will be cleared.

Parameters
[in]xFirst integer value.
[in]ySecond integer value.
[in]zThird integer value.
[in]wFourth integer value.
void createFromDouble ( double  x,
double  y = 0,
double  z = 0,
double  w = 0 
)

Create this object from 4 doubles.

Data already stored in this class will be cleared.

Parameters
[in]xFirst double value.
[in]ySecond double value.
[in]zThird double value.
[in]wFourth double value.
bool createFromList ( void *  pythonList,
unsigned int  length 
)

Create this object with a python list and length.

For example: scriptUtil.createFromList( (1.0,3.0,5.0,7.0,8.0,10.0,33.0), 7 ) Data already stored in this class will be cleared.

Parameters
[in]pythonListPython list of numeric values.
[in]lengthNumber of elements in the list.
int * asIntPtr ( )

Return an integer pointer to the data of this class.

NOTE: any previous pointer information returned by this object will be deleted.

short * asShortPtr ( )

Return a short pointer to the data of this class.

NOTE: any previous pointer information returned by this object will be deleted.

unsigned short * asUshortPtr ( )

Return an unsigned short pointer to the data of this class.

NOTE: any previous pointer information returned by this object will be deleted.

float * asFloatPtr ( )

Return a float pointer to the data of this class.

NOTE: any previous pointer information returned by this object will be deleted.

double * asDoublePtr ( )

Return a double pointer to the data of this class.

NOTE: any previous pointer information returned by this object will be deleted.

unsigned int * asUintPtr ( )

Return an unsigned integer pointer to the data of this class.

NOTE: any previous pointer information returned by this object will be deleted.

bool * asBoolPtr ( )

Return a bool pointer to the data of this class.

NOTE: any previous pointer information returned by this object will be deleted.

char * asCharPtr ( )

Return a char pointer to the data of this class.

NOTE: any previous pointer information returned by this object will be deleted.

unsigned char * asUcharPtr ( )

Return a unsigned char pointer to the data of this class.

NOTE: any previous pointer information returned by this object will be deleted.

Mint2 * asInt2Ptr ( )

Copy the data to a temporary array of the right type and return its address.

Ensure that this object has been created with sufficient data.

Warning
The data pointed to is only valid until the next call to any of the similar asType[234]Ptr methods.
Returns
A pointer to an array of 2 int.
Mint3 * asInt3Ptr ( )

Copy the data to a temporary array of the right type and return its address.

Ensure that this object has been created with sufficient data.

Warning
The data pointed to is only valid until the next call to any of the similar asType[234]Ptr methods.
Returns
A pointer to an array of 3 int.
Mint4 * asInt4Ptr ( )

Copy the data to a temporary array of the right type and return its address.

Ensure that this object has been created with sufficient data.

Warning
The data pointed to is only valid until the next call to any of the similar asType[234]Ptr methods.
Returns
A pointer to an array of 4 int.
Mshort2 * asShort2Ptr ( )

Copy the data to a temporary array of the right type and return its address.

Ensure that this object has been created with sufficient data.

Warning
The data pointed to is only valid until the next call to any of the similar asType[234]Ptr methods.
Returns
A pointer to an array of 2 short.
Mshort3 * asShort3Ptr ( )

Copy the data to a temporary array of the right type and return its address.

Ensure that this object has been created with sufficient data.

Warning
The data pointed to is only valid until the next call to any of the similar asType[234]Ptr methods.
Returns
A pointer to an array of 3 short.
Mshort4 * asShort4Ptr ( )

Copy the data to a temporary array of the right type and return its address.

Ensure that this object has been created with sufficient data.

Warning
The data pointed to is only valid until the next call to any of the similar asType[234]Ptr methods.
Returns
A pointer to an array of 4 short.
Mfloat2 * asFloat2Ptr ( )

Copy the data to a temporary array of the right type and return its address.

Ensure that this object has been created with sufficient data.

Warning
The data pointed to is only valid until the next call to any of the similar asType[234]Ptr methods.
Returns
A pointer to an array of 2 float.
Mfloat3 * asFloat3Ptr ( )

Copy the data to a temporary array of the right type and return its address.

Ensure that this object has been created with sufficient data.

Warning
The data pointed to is only valid until the next call to any of the similar asType[234]Ptr methods.
Returns
A pointer to an array of 3 float.
Mfloat4 * asFloat4Ptr ( )

Copy the data to a temporary array of the right type and return its address.

Ensure that this object has been created with sufficient data.

Warning
The data pointed to is only valid until the next call to any of the similar asType[234]Ptr methods.
Returns
A pointer to an array of 4 float.
Mdouble2 * asDouble2Ptr ( )

Copy the data to a temporary array of the right type and return its address.

Ensure that this object has been created with sufficient data.

Warning
The data pointed to is only valid until the next call to any of the similar asType[234]Ptr methods.
Returns
A pointer to an array of 2 double.
Mdouble3 * asDouble3Ptr ( )

Copy the data to a temporary array of the right type and return its address.

Ensure that this object has been created with sufficient data.

Warning
The data pointed to is only valid until the next call to any of the similar asType[234]Ptr methods.
Returns
A pointer to an array of 3 double.
Mdouble4 * asDouble4Ptr ( )

Copy the data to a temporary array of the right type and return its address.

Ensure that this object has been created with sufficient data.

Warning
The data pointed to is only valid until the next call to any of the similar asType[234]Ptr methods.
Returns
A pointer to an array of 4 double.
Muint2 * asUint2Ptr ( )

Copy the data to a temporary array of the right type and return its address.

Ensure that this object has been created with sufficient data.

Warning
The data pointed to is only valid until the next call to any of the similar asType[234]Ptr methods.
Returns
A pointer to an array of 2 unsigned int.
Muint3 * asUint3Ptr ( )

Copy the data to a temporary array of the right type and return its address.

Ensure that this object has been created with sufficient data.

Warning
The data pointed to is only valid until the next call to any of the similar asType[234]Ptr methods.
Returns
A pointer to an array of 3 unsigned int.
Muint4 * asUint4Ptr ( )

Copy the data to a temporary array of the right type and return its address.

Ensure that this object has been created with sufficient data.

Warning
The data pointed to is only valid until the next call to any of the similar asType[234]Ptr methods.
Returns
A pointer to an array of 4 unsigned int.
void setInt ( int &  var,
int  value 
)
static

Set an integer reference value.

Parameters
[out]varReference to the variable to be assigned.
[in]valueValue to assign
void setShort ( short &  var,
int  value 
)
static

Set a short reference value.

Parameters
[out]varReference to the variable to be assigned.
[in]valueValue to assign
void setFloat ( float &  var,
double  value 
)
static

Set a float reference value.

Parameters
[out]varReference to the variable to be assigned.
[in]valueValue to assign
void setDouble ( double &  var,
double  value 
)
static

Set a double reference value.

Parameters
[out]varReference to the variable to be assigned.
[in]valueValue to assign
void setUint ( unsigned int &  var,
int  value 
)
static

Set an unsigned integer reference value.

Parameters
[out]varReference to the variable to be assigned.
[in]valueValue to assign
void setBool ( bool &  var,
int  value 
)
static

Set a bool reference value.

Parameters
[out]varReference to the variable to be assigned.
[in]valueValue to assign
void setChar ( char &  var,
int  value 
)
static

Set a char reference value.

Parameters
[out]varReference to the variable to be assigned.
[in]valueValue to assign
void setUchar ( unsigned char &  var,
int  value 
)
static

Set an unsigned char reference value.

Parameters
[out]varReference to the variable to be assigned.
[in]valueValue to assign
int getInt ( int &  var)
static

Get the value of an integer reference.

Parameters
[in]varReference to the variable to return.
int getShort ( short &  var)
static

Get the value of a short reference.

Parameters
[in]varReference to the variable to return.
double getFloat ( float &  var)
static

Get the values of a float reference.

Parameters
[in]varReference to the variable to return.
double getDouble ( double &  var)
static

Get the value of a double reference.

Parameters
[in]varReference to the variable to return.
int getUint ( unsigned int &  var)
static

Get the value of an unsigned int reference.

Parameters
[in]varReference to the variable to return.
int getBool ( bool &  var)
static

Get the value of a bool reference.

Parameters
[in]varReference to the variable to return.
int getChar ( char &  var)
static

Get the value of a char reference.

Parameters
[in]varReference to the variable to return.
int getUchar ( unsigned char &  var)
static

Get the value of an unsigned char reference.

Parameters
[in]varReference to the variable to return.
bool setIntArray ( int *  var,
unsigned int  index,
int  value 
)
static

Set an integer value in an array.

Ensure that index is valid before calling this method.

Parameters
[out]varArray to assign to.
[in]indexIndex of the element to be modified.
[in]valueNew value to be assigned.
Returns
True on success, false otherwise.
bool setShortArray ( short *  var,
unsigned int  index,
int  value 
)
static

Set a short value in an array.

Ensure that index is valid before calling this method.

Parameters
[out]varArray to assign to.
[in]indexIndex of the element to be modified.
[in]valueNew value to be assigned.
Returns
True on success, false otherwise.
bool setFloatArray ( float *  var,
unsigned int  index,
double  value 
)
static

Set a float value in an array.

Ensure that index is valid before calling this method.

Parameters
[out]varArray to assign to.
[in]indexIndex of the element to be modified.
[in]valueNew value to be assigned.
Returns
True on success, false otherwise.
bool setDoubleArray ( double *  var,
unsigned int  index,
double  value 
)
static

Set a double value in an array.

Ensure that index is valid before calling this method.

Parameters
[out]varArray to assign to.
[in]indexIndex of the element to be modified.
[in]valueNew value to be assigned.
Returns
True on success, false otherwise.
bool setUintArray ( unsigned int *  var,
unsigned int  index,
int  value 
)
static

Set an unsigned integer value in an array.

Ensure that index is valid before calling this method.

Parameters
[out]varArray to assign to.
[in]indexIndex of the element to be modified.
[in]valueNew value to be assigned.
Returns
True on success, false otherwise.
bool setUshortArray ( unsigned short *  var,
unsigned int  index,
int  value 
)
static

Set an unsigned short value in an array.

Ensure that index is valid before calling this method.

Parameters
[out]varArray to assign to.
[in]indexIndex of the element to be modified.
[in]valueNew value to be assigned.
Returns
True on success, false otherwise.
bool setBoolArray ( bool *  var,
unsigned int  index,
int  value 
)
static

Set a bool value in an array.

Ensure that index is valid before calling this method.

Parameters
[out]varArray to assign to.
[in]indexIndex of the element to be modified.
[in]valueNew value to be assigned.
Returns
True on success, false otherwise.
bool setCharArray ( char *  var,
unsigned int  index,
int  value 
)
static

Set a char value in an array.

Ensure that index is valid before calling this method.

Parameters
[out]varArray to assign to.
[in]indexIndex of the element to be modified.
[in]valueNew value to be assigned.
Returns
True on success, false otherwise.
bool setUcharArray ( unsigned char *  var,
unsigned int  index,
int  value 
)
static

Set an unsigned char value in an array.

Ensure that index is valid before calling this method.

Parameters
[out]varArray to assign to.
[in]indexIndex of the element to be modified.
[in]valueNew value to be assigned.
Returns
True on success, false otherwise.
int getIntArrayItem ( int *  var,
unsigned int  index 
)
static

Get a int value from an array.

Ensure that index is valid before calling this method.

Parameters
[in]varArray to read from.
[in]indexIndex of the element to be returned.
Returns
Value of the element.
int getShortArrayItem ( short *  var,
unsigned int  index 
)
static

Get a short value from an array.

Ensure that index is valid before calling this method.

Parameters
[in]varArray to read from.
[in]indexIndex of the element to be returned.
Returns
Value of the element.
double getFloatArrayItem ( float *  var,
unsigned int  index 
)
static

Get a float value from an array.

Ensure that index is valid before calling this method.

Parameters
[in]varArray to read from.
[in]indexIndex of the element to be returned.
Returns
Value of the element.
double getDoubleArrayItem ( double *  var,
unsigned int  index 
)
static

Get a double value from an array.

Ensure that index is valid before calling this method.

Parameters
[in]varArray to read from.
[in]indexIndex of the element to be returned.
Returns
Value of the element.
int getUintArrayItem ( unsigned int *  var,
unsigned int  index 
)
static

Get an unsigned value from an array.

Ensure that index is valid before calling this method.

Parameters
[in]varArray to read from.
[in]indexIndex of the element to be returned.
Returns
Value of the element.
int getUshortArrayItem ( unsigned short *  var,
unsigned int  index 
)
static

Get an unsigned short value from an array.

Ensure that index is valid before calling this method.

Parameters
[in]varArray to read from.
[in]indexIndex of the element to be returned.
Returns
Value of the element.
int getBoolArrayItem ( bool *  var,
unsigned int  index 
)
static

Get a bool value from an array.

Ensure that index is valid before calling this method.

Parameters
[in]varArray to read from.
[in]indexIndex of the element to be returned.
Returns
Value of the element.
int getCharArrayItem ( char *  var,
unsigned int  index 
)
static

Get a char value from an array.

Ensure that index is valid before calling this method.

Parameters
[in]varArray to read from.
[in]indexIndex of the element to be returned.
Returns
Value of the element.
int getUcharArrayItem ( unsigned char *  var,
unsigned int  index 
)
static

Get an unsigned char value from an array.

Ensure that index is valid before calling this method.

Parameters
[in]varArray to read from.
[in]indexIndex of the element to be returned.
Returns
Value of the element.
bool createMatrixFromList ( void *  pythonList,
MMatrix matrix 
)
static

Create an MMatrix object from a list of 16 doubles.

The pythonList parameter must be a python list (1.0,2.0,...).

Calling this method from C++ is not advised.

Parameters
[in]pythonListPython list of 16 numeric values.
[out]matrixResulting matrix.
Returns
True if the conversion is successful, false otherwise.
bool createFloatMatrixFromList ( void *  pythonList,
MFloatMatrix matrix 
)
static

Create an MFloatMatrix object from a list of 16 doubles.

The pythonList parameter must be a python list (1.0,2.0,...).

Calling this method from C++ is not advised.

Parameters
[in]pythonListPython list of 16 numeric values.
[out]matrixResulting matrix.
Returns
True if the conversion is successful, false otherwise.
bool createIntArrayFromList ( void *  pythonList,
MIntArray array 
)
static

Create an MIntArray object from a python list.

The pythonList parameter must be a python list (1.0,2.0,...).

Calling this method from C++ is not advised.

Parameters
[in]pythonListPython list of 16 numeric values.
[out]arrayResulting array.
Returns
True if the conversion is successful, false otherwise.
bool createFloatArrayFromList ( void *  pythonList,
MFloatArray array 
)
static

Create an MFloatArray object from a python list.

The pythonList parameter must be a python list (1.0,2.0,...).

Calling this method from C++ is not advised.

Parameters
[in]pythonListPython list of 16 numeric values.
[out]arrayResulting array.
Returns
True if the conversion is successful, false otherwise.
int getInt2ArrayItem ( int(*)  var[2],
unsigned int  r,
unsigned int  c 
)
static

Get a value from the two dimensional array.

Ensure that indicies are valid before calling this method.

Parameters
[in]varArray to read from.
[in]rFirst index in the array.
[in]cSecond index in the array.
Returns
Value of the element: var[r][c]
bool setInt2ArrayItem ( int(*)  var[2],
unsigned int  r,
unsigned int  c,
int  value 
)
static

Set a value in the two dimensional array.

Ensure that indices are valid before calling this method.

Parameters
[in]varArray to assign to.
[in]rFirst index in the array.
[in]cSecond index in the array.
[in]valueValue to set into the element.
Returns
True on success, false otherwise.
int getInt3ArrayItem ( int(*)  var[3],
unsigned int  r,
unsigned int  c 
)
static

Get a value from the three dimensional array.

Ensure that indicies are valid before calling this method.

Parameters
[in]varArray to read from.
[in]rFirst index in the array.
[in]cSecond index in the array.
Returns
Value of the element: var[r][c]
bool setInt3ArrayItem ( int(*)  var[3],
unsigned int  r,
unsigned int  c,
int  value 
)
static

Set a value in the three dimensional array.

Ensure that indices are valid before calling this method.

Parameters
[in]varArray to assign to.
[in]rFirst index in the array.
[in]cSecond index in the array.
[in]valueValue to set into the element.
Returns
True on success, false otherwise.
int getInt4ArrayItem ( int(*)  var[4],
unsigned int  r,
unsigned int  c 
)
static

Get a value from the four dimensional array.

Ensure that indicies are valid before calling this method.

Parameters
[in]varArray to read from.
[in]rFirst index in the array.
[in]cSecond index in the array.
Returns
Value of the element: var[r][c]
bool setInt4ArrayItem ( int(*)  var[4],
unsigned int  r,
unsigned int  c,
int  value 
)
static

Set a value in the four dimensional array.

Ensure that indices are valid before calling this method.

Parameters
[in]varArray to assign to.
[in]rFirst index in the array.
[in]cSecond index in the array.
[in]valueValue to set into the element.
Returns
True on success, false otherwise.
short getShort2ArrayItem ( short(*)  var[2],
unsigned int  r,
unsigned int  c 
)
static

Get a value from the two dimensional array.

Ensure that indicies are valid before calling this method.

Parameters
[in]varArray to read from.
[in]rFirst index in the array.
[in]cSecond index in the array.
Returns
Value of the element: var[r][c]
bool setShort2ArrayItem ( short(*)  var[2],
unsigned int  r,
unsigned int  c,
short  value 
)
static

Set a value in the two dimensional array.

Ensure that indices are valid before calling this method.

Parameters
[in]varArray to assign to.
[in]rFirst index in the array.
[in]cSecond index in the array.
[in]valueValue to set into the element.
Returns
True on success, false otherwise.
short getShort3ArrayItem ( short(*)  var[3],
unsigned int  r,
unsigned int  c 
)
static

Get a value from the three dimensional array.

Ensure that indicies are valid before calling this method.

Parameters
[in]varArray to read from.
[in]rFirst index in the array.
[in]cSecond index in the array.
Returns
Value of the element: var[r][c]
bool setShort3ArrayItem ( short(*)  var[3],
unsigned int  r,
unsigned int  c,
short  value 
)
static

Set a value in the three dimensional array.

Ensure that indices are valid before calling this method.

Parameters
[in]varArray to assign to.
[in]rFirst index in the array.
[in]cSecond index in the array.
[in]valueValue to set into the element.
Returns
True on success, false otherwise.
short getShort4ArrayItem ( short(*)  var[4],
unsigned int  r,
unsigned int  c 
)
static

Get a value from the four dimensional array.

Ensure that indicies are valid before calling this method.

Parameters
[in]varArray to read from.
[in]rFirst index in the array.
[in]cSecond index in the array.
Returns
Value of the element: var[r][c]
bool setShort4ArrayItem ( short(*)  var[4],
unsigned int  r,
unsigned int  c,
short  value 
)
static

Set a value in the two dimensional array.

Ensure that indices are valid before calling this method.

Parameters
[in]varArray to assign to.
[in]rFirst index in the array.
[in]cSecond index in the array.
[in]valueValue to set into the element.
Returns
True on success, false otherwise.
float getFloat2ArrayItem ( float(*)  var[2],
unsigned int  r,
unsigned int  c 
)
static

Get a value from the two dimensional array.

Ensure that indicies are valid before calling this method.

Parameters
[in]varArray to read from.
[in]rFirst index in the array.
[in]cSecond index in the array.
Returns
Value of the element: var[r][c]
bool setFloat2ArrayItem ( float(*)  var[2],
unsigned int  r,
unsigned int  c,
float  value 
)
static

Set a value in the two dimensional array.

Ensure that indices are valid before calling this method.

Parameters
[in]varArray to assign to.
[in]rFirst index in the array.
[in]cSecond index in the array.
[in]valueValue to set into the element.
Returns
True on success, false otherwise.
float getFloat3ArrayItem ( float(*)  var[3],
unsigned int  r,
unsigned int  c 
)
static

Get a value from the three dimensional array.

Ensure that indicies are valid before calling this method.

Parameters
[in]varArray to read from.
[in]rFirst index in the array.
[in]cSecond index in the array.
Returns
Value of the element: var[r][c]
bool setFloat3ArrayItem ( float(*)  var[3],
unsigned int  r,
unsigned int  c,
float  value 
)
static

Set a value in the three dimensional array.

Ensure that indices are valid before calling this method.

Parameters
[in]varArray to assign to.
[in]rFirst index in the array.
[in]cSecond index in the array.
[in]valueValue to set into the element.
Returns
True on success, false otherwise.
float getFloat4ArrayItem ( float(*)  var[4],
unsigned int  r,
unsigned int  c 
)
static

Get a value from the four dimensional array.

Ensure that indicies are valid before calling this method.

Parameters
[in]varArray to read from.
[in]rFirst index in the array.
[in]cSecond index in the array.
Returns
Value of the element: var[r][c]
bool setFloat4ArrayItem ( float(*)  var[4],
unsigned int  r,
unsigned int  c,
float  value 
)
static

Set a value in the four dimensional array.

Ensure that indices are valid before calling this method.

Parameters
[in]varArray to assign to.
[in]rFirst index in the array.
[in]cSecond index in the array.
[in]valueValue to set into the element.
Returns
True on success, false otherwise.
double getDouble2ArrayItem ( double(*)  var[2],
unsigned int  r,
unsigned int  c 
)
static

Get a value from the two dimensional array.

Ensure that indicies are valid before calling this method.

Parameters
[in]varArray to read from.
[in]rFirst index in the array.
[in]cSecond index in the array.
Returns
Value of the element: var[r][c]
bool setDouble2ArrayItem ( double(*)  var[2],
unsigned int  r,
unsigned int  c,
double  value 
)
static

Set a value in the two dimensional array.

Ensure that indices are valid before calling this method.

Parameters
[in]varArray to assign to.
[in]rFirst index in the array.
[in]cSecond index in the array.
[in]valueValue to set into the element.
Returns
True on success, false otherwise.
double getDouble3ArrayItem ( double(*)  var[3],
unsigned int  r,
unsigned int  c 
)
static

Get a value from the three dimensional array.

Ensure that indicies are valid before calling this method.

Parameters
[in]varArray to read from.
[in]rFirst index in the array.
[in]cSecond index in the array.
Returns
Value of the element: var[r][c]
bool setDouble3ArrayItem ( double(*)  var[3],
unsigned int  r,
unsigned int  c,
double  value 
)
static

Set a value in the three dimensional array.

Ensure that indices are valid before calling this method.

Parameters
[in]varArray to assign to.
[in]rFirst index in the array.
[in]cSecond index in the array.
[in]valueValue to set into the element.
Returns
True on success, false otherwise.
double getDouble4ArrayItem ( double(*)  var[4],
unsigned int  r,
unsigned int  c 
)
static

Get a value from the four dimensional array.

Ensure that indicies are valid before calling this method.

Parameters
[in]varArray to read from.
[in]rFirst index in the array.
[in]cSecond index in the array.
Returns
Value of the element: var[r][c]
bool setDouble4ArrayItem ( double(*)  var[4],
unsigned int  r,
unsigned int  c,
double  value 
)
static

Set a value in the four dimensional array.

Ensure that indices are valid before calling this method.

Parameters
[in]varArray to assign to.
[in]rFirst index in the array.
[in]cSecond index in the array.
[in]valueValue to set into the element.
Returns
True on success, false otherwise.
unsigned int getUint2ArrayItem ( unsigned int(*)  var[2],
unsigned int  r,
unsigned int  c 
)
static

Get a value from the two dimensional array.

Ensure that indicies are valid before calling this method.

Parameters
[in]varArray to read from.
[in]rFirst index in the array.
[in]cSecond index in the array.
Returns
Value of the element: var[r][c]
bool setUint2ArrayItem ( unsigned int(*)  var[2],
unsigned int  r,
unsigned int  c,
unsigned int  value 
)
static

Set a value in the two dimensional array.

Ensure that indices are valid before calling this method.

Parameters
[in]varArray to assign to.
[in]rFirst index in the array.
[in]cSecond index in the array.
[in]valueValue to set into the element.
Returns
True on success, false otherwise.
unsigned int getUint3ArrayItem ( unsigned int(*)  var[3],
unsigned int  r,
unsigned int  c 
)
static

Get a value from the three dimensional array.

Ensure that indicies are valid before calling this method.

Parameters
[in]varArray to read from.
[in]rFirst index in the array.
[in]cSecond index in the array.
Returns
Value of the element: var[r][c]
bool setUint3ArrayItem ( unsigned int(*)  var[3],
unsigned int  r,
unsigned int  c,
unsigned int  value 
)
static

Set a value in the three dimensional array.

Ensure that indices are valid before calling this method.

Parameters
[in]varArray to assign to.
[in]rFirst index in the array.
[in]cSecond index in the array.
[in]valueValue to set into the element.
Returns
True on success, false otherwise.
unsigned int getUint4ArrayItem ( unsigned int(*)  var[4],
unsigned int  r,
unsigned int  c 
)
static

Get a value from the four dimensional array.

Ensure that indicies are valid before calling this method.

Parameters
[in]varArray to read from.
[in]rFirst index in the array.
[in]cSecond index in the array.
Returns
Value of the element: var[r][c]
bool setUint4ArrayItem ( unsigned int(*)  var[4],
unsigned int  r,
unsigned int  c,
unsigned int  value 
)
static

Set a value in the four dimensional array.

Ensure that indices are valid before calling this method.

Parameters
[in]varArray to assign to.
[in]rFirst index in the array.
[in]cSecond index in the array.
[in]valueValue to set into the element.
Returns
True on success, false otherwise.

The documentation for this class was generated from the following files:
  • MScriptUtil.h
  • MScriptUtil.cpp