class MScriptUtil

Jump to documentation

Utility class for working with pointers and references. (OpenMaya) (OpenMaya.py)

public members:

MScriptUtil ()
~MScriptUtil ()
MScriptUtil ( int& value )
MScriptUtil ( short& value )
MScriptUtil ( float& value )
MScriptUtil ( double& value )
MScriptUtil ( unsigned int& value )
MScriptUtil ( bool& value )
MScriptUtil ( MIntArray & array )
MScriptUtil ( MDoubleArray & array )
MScriptUtil ( MUintArray & array )
MScriptUtil ( MUint64Array & array )
void createFromInt ( int x, int y=0, int z=0, int w=0 )
void createFromDouble ( double x, double y=0, double z=0, double w=0 )
bool createFromList ( void *pythonList, unsigned int length )
int asInt ()
short asShort ()
float asFloat ()
double asDouble ()
unsigned int asUint ()
bool asBool ()
int *asIntPtr ()
short *asShortPtr ()
float *asFloatPtr ()
double *asDoublePtr ()
unsigned int *asUintPtr ()
bool* asBoolPtr ()
char *asCharPtr ()
unsigned char *asUcharPtr ()
static void setInt ( int& var, int value )
static void setShort ( short& var, int value )
static void setFloat ( float& var, double value )
static void setDouble ( double& var, double value )
static void setUint ( unsigned int& var, int value )
static void setBool ( bool& var, int value )
static void setChar ( char& var, int value )
static void setUchar ( unsigned char& var, int value )
static int getInt ( int& var )
static int getShort ( short& var )
static double getFloat ( float& var )
static double getDouble ( double& var )
static int getUint ( unsigned int& var )
static int getBool ( bool& var )
static int getChar ( char& var )
static int getUchar ( unsigned char& var )
static bool setIntArray ( int* var, unsigned int index, int value )
static bool setShortArray ( short* var, unsigned int index, int value )
static bool setFloatArray ( float* var, unsigned int index, double value )
static bool setDoubleArray ( double* var, unsigned int index, double value )
static bool setUintArray ( unsigned int* var, unsigned int index, int value )
static bool setBoolArray ( bool* var, unsigned int index, int value )
static bool setCharArray ( char* var, unsigned int index, int value )
static bool setUcharArray ( unsigned char* var, unsigned int index, int value )
static int getIntArrayItem ( int* var, unsigned int index )
static int getShortArrayItem ( short* var, unsigned int index )
static double getFloatArrayItem ( float* var, unsigned int index )
static double getDoubleArrayItem ( double* var, unsigned int index )
static int getUintArrayItem ( unsigned int* var, unsigned int index )
static int getBoolArrayItem ( bool* var, unsigned int index )
static int getCharArrayItem ( char* var, unsigned int index )
static int getUcharArrayItem ( unsigned char* var, unsigned int index )
static bool createMatrixFromList ( void *pythonList, MMatrix & matrix )
static bool createFloatMatrixFromList ( void *pythonList, MFloatMatrix & matrix )
static bool createIntArrayFromList ( void *pythonList, MIntArray & array )
static bool createFloatArrayFromList ( void *pythonList, MFloatArray & array )
static int getInt2ArrayItem ( int (*var)[2], unsigned int r, unsigned int c)
static bool setInt2ArrayItem ( int (*var)[2], unsigned int r, unsigned int c, int value )
static int getInt3ArrayItem ( int (*var)[3], unsigned int r, unsigned int c)
static bool setInt3ArrayItem ( int (*var)[3], unsigned int r, unsigned int c, int value )
static int getInt4ArrayItem ( int (*var)[4], unsigned int r, unsigned int c)
static bool setInt4ArrayItem ( int (*var)[4], unsigned int r, unsigned int c, int value )
static short getShort2ArrayItem ( short (*var)[2], unsigned int r, unsigned int c)
static bool setShort2ArrayItem ( short (*var)[2], unsigned int r, unsigned int c, short value )
static short getShort3ArrayItem ( short (*var)[3], unsigned int r, unsigned int c)
static bool setShort3ArrayItem ( short (*var)[3], unsigned int r, unsigned int c, short value )
static short getShort4ArrayItem ( short (*var)[4], unsigned int r, unsigned int c)
static bool setShort4ArrayItem ( short (*var)[4], unsigned int r, unsigned int c, short value )
static float getFloat2ArrayItem ( float (*var)[2], unsigned int r, unsigned int c)
static bool setFloat2ArrayItem ( float (*var)[2], unsigned int r, unsigned int c, float value )
static float getFloat3ArrayItem ( float (*var)[3], unsigned int r, unsigned int c)
static bool setFloat3ArrayItem ( float (*var)[3], unsigned int r, unsigned int c, float value )
static float getFloat4ArrayItem ( float (*var)[4], unsigned int r, unsigned int c)
static bool setFloat4ArrayItem ( float (*var)[4], unsigned int r, unsigned int c, float value )
static double getDouble2ArrayItem ( double (*var)[2], unsigned int r, unsigned int c)
static bool setDouble2ArrayItem ( double (*var)[2], unsigned int r, unsigned int c, double value )
static double getDouble3ArrayItem ( double (*var)[3], unsigned int r, unsigned int c)
static bool setDouble3ArrayItem ( double (*var)[3], unsigned int r, unsigned int c, double value )
static double getDouble4ArrayItem ( double (*var)[4], unsigned int r, unsigned int c)
static bool setDouble4ArrayItem ( double (*var)[4], unsigned int r, unsigned int c, double value )
static unsigned int getUint2ArrayItem ( unsigned int (*var)[2], unsigned int r, unsigned int c)
static bool setUint2ArrayItem ( unsigned int (*var)[2], unsigned int r, unsigned int c, unsigned int value )
static unsigned int getUint3ArrayItem ( unsigned int (*var)[3], unsigned int r, unsigned int c)
static bool setUint3ArrayItem ( unsigned int (*var)[3], unsigned int r, unsigned int c, unsigned int value )
static unsigned int getUint4ArrayItem ( unsigned int (*var)[4], unsigned int r, unsigned int c)
static bool setUint4ArrayItem ( unsigned int (*var)[4], unsigned int r, unsigned int c, unsigned int value )

Documentation

General class for scripting.
Description

Utility class for working with pointers to basic types such as int, float and arrays of these types. Class is more applicable for script programming rather than C++. C++ pointers and references have no equivalent in script so this class provides utility methods for working with these type of parameters and return values.

References are treated as pointers in script. This class allows creating data and then acquiring a pointer to the data so that information can be passed to class methods requiring references.

Common scenarios: 1. A reference to an integer is required for a parameter: create the MScriptUtil object with the integer create() method, acquire a pointer using asIntPtr(), pass that pointer to the method requiring the reference, create another MScriptUtil object using the int pointer that was returned, query the integer return value using asInt(). 2. A pointer to a list of floats are required for a parameter: create the MScriptUtil object with createFromList(), call asFloatPointer() and pass that to the method. 3. Several static methods are available for converting python lists to matrices and integer/float arrays.

This class is cumbersome to use but it provides a way of building parameters and accessing return values for methods which would normally not be scriptable.

Functions

MScriptUtil:: MScriptUtil ()

Description

Default constructor. The instance is set to contain no elements.

MScriptUtil:: MScriptUtil ( int& value )

Description

Instantiate class with an int reference.

MScriptUtil:: MScriptUtil ( short& value )

Description

Instantiate class with an short reference.

MScriptUtil:: MScriptUtil ( float& value )

Description

Instantiate class with an float reference.

MScriptUtil:: MScriptUtil ( double& value )

Description

Instantiate class with an double reference.

MScriptUtil:: MScriptUtil ( unsigned int& value )

Description

Instantiate class with an unsigned int reference.

MScriptUtil:: MScriptUtil ( bool& value )

Description

Instantiate class with an bool reference.

MScriptUtil:: MScriptUtil ( MIntArray & array )

Description

Instantiate class with an integer array.

MScriptUtil:: MScriptUtil ( MDoubleArray & array )

Description

Instantiate class with an double array.

MScriptUtil:: MScriptUtil ( MUintArray & array )

Description

Instantiate class with an unsigned integer array.

MScriptUtil:: MScriptUtil ( MUint64Array & array )

Description

Instantiate class with an unsigned integer array.

MScriptUtil:: ~MScriptUtil ()

Description

Destructor.

void MScriptUtil:: createFromInt ( int x, int y, int z, int w )

Description

Create this object from 4 integers. Data already stored in this class will be cleared.

void MScriptUtil:: createFromDouble ( double x, double y, double z, double w )

Description

Create this object from 4 doubles. Data already stored in this class will be cleared.

bool MScriptUtil:: createFromList ( void *pythonList, unsigned int length )

Description

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.

int MScriptUtil:: asInt ()

Description

Return the first item added to this object as an integer.

short MScriptUtil:: asShort ()

Description

Return the first item added to this object as a short.

float MScriptUtil:: asFloat ()

Description

Return the first item added to this object as a float.

double MScriptUtil:: asDouble ()

Description

Return the first item added to this object as a double.

unsigned int MScriptUtil:: asUint ()

Description

Return the first item added to this object as a unsigned integer.

bool MScriptUtil:: asBool ()

Description

Return the first item added to this object as a bool.

int *MScriptUtil:: asIntPtr ()

Description

Return an integer pointer to the data of this class.

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

short *MScriptUtil:: asShortPtr ()

Description

Return a short pointer to the data of this class.

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

float *MScriptUtil:: asFloatPtr ()

Description

Return a float pointer to the data of this class.

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

double *MScriptUtil:: asDoublePtr ()

Description

Return a double pointer to the data of this class.

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

unsigned int *MScriptUtil:: asUintPtr ()

Description

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

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

bool* MScriptUtil:: asBoolPtr ()

Description

Return a bool pointer to the data of this class.

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

char *MScriptUtil:: asCharPtr ()

Description

Return a char pointer to the data of this class.

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

unsigned char *MScriptUtil:: asUcharPtr ()

Description

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

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

int (*MScriptUtil::asInt2Ptr())

Description

Return an integer pointer [][2] for the data of this class. Ensure that this object has been created with sufficient data.

int (*MScriptUtil::asInt3Ptr())

Description

Return an integer pointer [][3] for the data of this class. Ensure that this object has been created with sufficient data.

int (*MScriptUtil::asInt4Ptr())

Description

Return an integer pointer [][3] for the data of this class. Ensure that this object has been created with sufficient data.

short (*MScriptUtil::asShort2Ptr())

Description

Return a short pointer [][2] for the data of this class. Ensure that this object has been created with sufficient data.

short (*MScriptUtil::asShort3Ptr())

Description

Return a short pointer [][3] for the data of this class. Ensure that this object has been created with sufficient data.

short (*MScriptUtil::asShort4Ptr())

Description

Return a short pointer [][4] for the data of this class. Ensure that this object has been created with sufficient data.

float (*MScriptUtil::asFloat2Ptr())

Description

Return a float pointer [][2] for the data of this class. Ensure that this object has been created with sufficient data.

float (*MScriptUtil::asFloat3Ptr())

Description

Return a float pointer [][3] for the data of this class. Ensure that this object has been created with sufficient data.

float (*MScriptUtil::asFloat4Ptr())

Description

Return a float pointer [][4] for the data of this class. Ensure that this object has been created with sufficient data.

double (*MScriptUtil::asDouble2Ptr())

Description

Return a float pointer [][2] for the data of this class. Ensure that this object has been created with sufficient data.

double (*MScriptUtil::asDouble3Ptr())

Description

Return a float pointer [][3] for the data of this class. Ensure that this object has been created with sufficient data.

double (*MScriptUtil::asDouble4Ptr())

Description

Return a float pointer [][4] for the data of this class. Ensure that this object has been created with sufficient data.

unsigned int (*MScriptUtil::asUint2Ptr())

Description

Return a float pointer [][2] for the data of this class. Ensure that this object has been created with sufficient data.

unsigned int (*MScriptUtil::asUint3Ptr())

Description

Return a float pointer [][3] for the data of this class. Ensure that this object has been created with sufficient data.

unsigned int (*MScriptUtil::asUint4Ptr())

Description

Return a float pointer [][4] for the data of this class. Ensure that this object has been created with sufficient data.

void MScriptUtil:: setInt ( int& var, int value )

Description

Set an integer reference value.

void MScriptUtil:: setShort ( short& var, int value )

Description

Set a short reference value.

void MScriptUtil:: setFloat ( float& var, double value )

Description

Set a float reference value.

void MScriptUtil:: setDouble ( double& var, double value )

Description

Set a double reference value.

void MScriptUtil:: setUint ( unsigned int& var, int value )

Description

Set an unsigned integer reference value.

void MScriptUtil:: setBool ( bool& var, int value )

Description

Set a bool reference value.

void MScriptUtil:: setChar ( char& var, int value )

Description

Set a char reference value.

void MScriptUtil:: setUchar ( unsigned char& var, int value )

Description

Set an unsigned char reference value.

int MScriptUtil:: getInt ( int& var )

Description

Get the value of an integer reference.

int MScriptUtil:: getShort ( short& var )

Description

Get the value of a short reference.

double MScriptUtil:: getFloat ( float& var )

Description

Get the values of a float reference.

double MScriptUtil:: getDouble ( double& var )

Description

Get the value of a double reference.

int MScriptUtil:: getUint ( unsigned int& var )

Description

Get the values of an unsigned int reference.

int MScriptUtil:: getBool ( bool& var )

Description

Get the value of a bool reference.

int MScriptUtil:: getChar ( char& var )

Description

Get the value of a char reference.

int MScriptUtil:: getUchar ( unsigned char& var )

Description

Get the value of an unsigned char reference.

bool MScriptUtil:: setIntArray ( int* var, unsigned int index, int value )

Description

Set an integer value in an array. Return true on success. False is return otherwise. Ensure that index is valid before calling this method.

bool MScriptUtil:: setShortArray ( short* var, unsigned int index, int value )

Description

Set a short value in an array. Return true on success. False is return otherwise. Ensure that index is valid before calling this method.

bool MScriptUtil:: setFloatArray ( float* var, unsigned int index, double value )

Description

Set a float value in an array. Return true on success. False is return otherwise. Ensure that index is valid before calling this method.

bool MScriptUtil:: setDoubleArray ( double* var, unsigned int index, double value )

Description

Set a double value in an array. Return true on success. False is return otherwise. Ensure that index is valid before calling this method.

bool MScriptUtil:: setUintArray ( unsigned int* var, unsigned int index, int value )

Description

Set an unsigned integer value in an array. Return true on success. False is return otherwise. Ensure that index is valid before calling this method.

bool MScriptUtil:: setBoolArray ( bool* var, unsigned int index, int value )

Description

Set a bool value in an array. Return true on success. False is return otherwise. Ensure that index is valid before calling this method.

bool MScriptUtil:: setCharArray ( char* var, unsigned int index, int value )

Description

Set a char value in an array. Return true on success. False is return otherwise. Ensure that index is valid before calling this method.

bool MScriptUtil:: setUcharArray ( unsigned char* var, unsigned int index, int value )

Description

Set an unsigned char value in an array. Return true on success. False is return otherwise. Ensure that index is valid before calling this method.

int MScriptUtil:: getIntArrayItem ( int* var, unsigned int index )

Description

Get a int value from an array. Ensure that index is valid before calling this method.

int MScriptUtil:: getShortArrayItem ( short* var, unsigned int index )

Description

Get a short value from an array. Ensure that index is valid before calling this method.

double MScriptUtil:: getFloatArrayItem ( float* var, unsigned int index )

Description

Get a float value from an array. Ensure that index is valid before calling this method.

double MScriptUtil:: getDoubleArrayItem ( double* var, unsigned int index )

Description

Get a double value from an array. Ensure that index is valid before calling this method.

int MScriptUtil:: getUintArrayItem ( unsigned int* var, unsigned int index )

Description

Get an unsigned value from an array. Ensure that index is valid before calling this method.

int MScriptUtil:: getBoolArrayItem ( bool* var, unsigned int index )

Description

Get a bool value from an array. Ensure that index is valid before calling this method.

int MScriptUtil:: getCharArrayItem ( char* var, unsigned int index )

Description

Get a char value from an array. Ensure that index is valid before calling this method.

int MScriptUtil:: getUcharArrayItem ( unsigned char* var, unsigned int index )

Description

Get an unsigned char value from an array. Ensure that index is valid before calling this method.

bool MScriptUtil:: createMatrixFromList ( void *pythonList, MMatrix & matrix )

Description

Create an MMatrix object from a list of 16 doubles. The pythonList parameter must be a python list (1.0,2.0,...). This method will return true if the conversion is successful. False is returned otherwise.

Calling this method from C++ is not advised.

bool MScriptUtil:: createFloatMatrixFromList ( void *pythonList, MFloatMatrix & matrix )

Description

Create an MFloatMatrix object from a list of 16 doubles. The pythonList parameter must be a python list (1.0,2.0,...). This method will return true if the conversion is successful. False is returned otherwise.

Calling this method from C++ is not advised.

bool MScriptUtil:: createIntArrayFromList ( void *pythonList, MIntArray & array )

Description

Create an MIntArray object from a python list. The pythonList parameter must be a python list (1.0,2.0,...). This method will return true if the conversion is successful. False is returned otherwise.

Calling this method from C++ is not advised.

bool MScriptUtil:: createFloatArrayFromList ( void *pythonList, MFloatArray & array )

Description

Create an MFloatArray object from a python list. The pythonList parameter must be a python list (1.0,2.0,...). This method will return true if the conversion is successful. False is returned otherwise.

Calling this method from C++ is not advised.

int MScriptUtil:: getInt2ArrayItem ( int (*var)[2], unsigned int r, unsigned int c)

Description

Get a value from the two dimensional array. Ensure that indicies are valid before calling this method.

bool MScriptUtil:: setInt2ArrayItem ( int (*var)[2], unsigned int r, unsigned int c, int value )

Description

Set a value in the two dimensional array. Return true on success. False is return otherwise. Ensure that indices are valid before calling this method.

int MScriptUtil:: getInt3ArrayItem ( int (*var)[3], unsigned int r, unsigned int c)

Description

Get a value from the two dimensional array. Ensure that indicies are valid before calling this method.

bool MScriptUtil:: setInt3ArrayItem ( int (*var)[3], unsigned int r, unsigned int c, int value )

Description

Set a value in the two dimensional array. Return true on success. False is return otherwise. Ensure that indices are valid before calling this method.

int MScriptUtil:: getInt4ArrayItem ( int (*var)[4], unsigned int r, unsigned int c)

Description

Get a value from the two dimensional array. Ensure that indicies are valid before calling this method.

bool MScriptUtil:: setInt4ArrayItem ( int (*var)[4], unsigned int r, unsigned int c, int value )

Description

Set a value in the two dimensional array. Return true on success. False is return otherwise. Ensure that indices are valid before calling this method.

short MScriptUtil:: getShort2ArrayItem ( short (*var)[2], unsigned int r, unsigned int c)

Description

Get a value from the two dimensional array. Ensure that indicies are valid before calling this method.

bool MScriptUtil:: setShort2ArrayItem ( short (*var)[2], unsigned int r, unsigned int c, short value )

Description

Set a value in the two dimensional array. Return true on success. False is return otherwise. Ensure that indices are valid before calling this method.

short MScriptUtil:: getShort3ArrayItem ( short (*var)[3], unsigned int r, unsigned int c)

Description

Get a value from the two dimensional array. Ensure that indicies are valid before calling this method.

bool MScriptUtil:: setShort3ArrayItem ( short (*var)[3], unsigned int r, unsigned int c, short value )

Description

Set a value in the two dimensional array. Return true on success. False is return otherwise. Ensure that indices are valid before calling this method.

short MScriptUtil:: getShort4ArrayItem ( short (*var)[4], unsigned int r, unsigned int c)

Description

Get a value from the two dimensional array. Ensure that indicies are valid before calling this method.

bool MScriptUtil:: setShort4ArrayItem ( short (*var)[4], unsigned int r, unsigned int c, short value )

Description

Set a value in the two dimensional array. Return true on success. False is return otherwise. Ensure that indices are valid before calling this method.

float MScriptUtil:: getFloat2ArrayItem ( float (*var)[2], unsigned int r, unsigned int c)

Description

Get a value from the two dimensional array. Ensure that indicies are valid before calling this method.

bool MScriptUtil:: setFloat2ArrayItem ( float (*var)[2], unsigned int r, unsigned int c, float value )

Description

Set a value in the two dimensional array. Return true on success. False is return otherwise. Ensure that indices are valid before calling this method.

float MScriptUtil:: getFloat3ArrayItem ( float (*var)[3], unsigned int r, unsigned int c)

Description

Get a value from the two dimensional array. Ensure that indicies are valid before calling this method.

bool MScriptUtil:: setFloat3ArrayItem ( float (*var)[3], unsigned int r, unsigned int c, float value )

Description

Set a value in the two dimensional array. Return true on success. False is return otherwise. Ensure that indices are valid before calling this method.

float MScriptUtil:: getFloat4ArrayItem ( float (*var)[4], unsigned int r, unsigned int c)

Description

Get a value from the two dimensional array. Ensure that indicies are valid before calling this method.

bool MScriptUtil:: setFloat4ArrayItem ( float (*var)[4], unsigned int r, unsigned int c, float value )

Description

Set a value in the two dimensional array. Return true on success. False is return otherwise. Ensure that indices are valid before calling this method.

double MScriptUtil:: getDouble2ArrayItem ( double (*var)[2], unsigned int r, unsigned int c)

Description

Get a value from the two dimensional array. Ensure that indicies are valid before calling this method.

bool MScriptUtil:: setDouble2ArrayItem ( double (*var)[2], unsigned int r, unsigned int c, double value )

Description

Set a value in the two dimensional array. Return true on success. False is return otherwise. Ensure that indices are valid before calling this method.

double MScriptUtil:: getDouble3ArrayItem ( double (*var)[3], unsigned int r, unsigned int c)

Description

Get a value from the two dimensional array. Ensure that indicies are valid before calling this method.

bool MScriptUtil:: setDouble3ArrayItem ( double (*var)[3], unsigned int r, unsigned int c, double value )

Description

Set a value in the two dimensional array. Return true on success. False is return otherwise. Ensure that indices are valid before calling this method.

double MScriptUtil:: getDouble4ArrayItem ( double (*var)[4], unsigned int r, unsigned int c)

Description

Get a value from the two dimensional array. Ensure that indicies are valid before calling this method.

bool MScriptUtil:: setDouble4ArrayItem ( double (*var)[4], unsigned int r, unsigned int c, double value )

Description

Set a value in the two dimensional array. Return true on success. False is return otherwise. Ensure that indices are valid before calling this method.

unsigned int MScriptUtil:: getUint2ArrayItem ( unsigned int (*var)[2], unsigned int r, unsigned int c)

Description

Get a value from the two dimensional array. Ensure that indicies are valid before calling this method.

bool MScriptUtil:: setUint2ArrayItem ( unsigned int (*var)[2], unsigned int r, unsigned int c, unsigned int value )

Description

Set a value in the two dimensional array. Return true on success. False is return otherwise. Ensure that indices are valid before calling this method.

unsigned int MScriptUtil:: getUint3ArrayItem ( unsigned int (*var)[3], unsigned int r, unsigned int c)

Description

Get a value from the two dimensional array. Ensure that indicies are valid before calling this method.

bool MScriptUtil:: setUint3ArrayItem ( unsigned int (*var)[3], unsigned int r, unsigned int c, unsigned int value )

Description

Set a value in the two dimensional array. Return true on success. False is return otherwise. Ensure that indices are valid before calling this method.

unsigned int MScriptUtil:: getUint4ArrayItem ( unsigned int (*var)[4], unsigned int r, unsigned int c)

Description

Get a value from the two dimensional array. Ensure that indicies are valid before calling this method.

bool MScriptUtil:: setUint4ArrayItem ( unsigned int (*var)[4], unsigned int r, unsigned int c, unsigned int value )

Description

Set a value in the two dimensional array. Return true on success. False is return otherwise. Ensure that indices are valid before calling this method.

This class has no child classes.


Autodesk® Maya® 2008 © 1997-2007 Autodesk, Inc. All rights reserved. doc++ Copyright