Published using Google Docs
naGeneral.txt
Updated automatically every 5 minutes

/**@file naGeneral.mel v1.0.2

@brief Tools for finding or selecting nodes(joints,materials,skinning,components),

naming and also has common string intersection tools

@author Nathaniel O. Anozie (ogbonnawork at gmail dot com)

@bug all functions no assert checks

@note date created: Nov 23 2011

@note date last modified: Apr 27 2012

@note How to Install

@note source na_General.mel

@see

@note released v1.0.1

@note v1.0.1  added getting specific type from a node

@note v1.0.2  --added string list intersection tools, added get plug using attribute array

-- fixed bug in na_isTypeSupported

@note Modify at your own risk

*/

/**

add a non keyable hidden float attribute on animator control

@param string $anim_control node to add attribute to

@param string $name name for attribute it creates

@pre control exists, name not an attribute currently on control

@bug no error checking

*/

global proc

na_addNonKeyFloatAttr(string $anim_control, string $name)

{

    addAttr -ln $name -at double $anim_control;

   

    //this is necessary so animator cannot accidentally key or delete this

    setAttr -e-keyable false -channelBox true ($anim_control+"."+$name);

}

/**return string array intersection of arg and option list

@result unordered string list of intersection

@param $arg -- what checking

@param $option -- avaliable options

*/

global proc string[]

na_getStringArrayIntersectWithOption(string $arg[], string $option[])

{

    na_getStringArrayIntersectWithOption_assert($arg,$option);

   

    string $result[] ={};

    string $na_intersector = `stringArrayIntersector`;

    stringArrayIntersector -edit -intersect $option $na_intersector;

   

    //is arg an option

    stringArrayIntersector -edit -intersect $arg $na_intersector;

   

    $result = `stringArrayIntersector -query $na_intersector`;

    //remove intersector

    deleteUI $na_intersector;

   

    return $result;

}

/**

*/

global proc

na_getStringArrayIntersectWithOption_assert(string $arg[], string $option[])

{

    if(size($arg) == 0 || size($option) == 0){error("expecting non-zero sizes of input");}

}

global proc

na_getStringArrayIntersectWithOption_unitTest()

{

    print( na_getStringArrayIntersectWithOption({"a","c"},{"a","b"}) );

    print("\n");

    print( na_getStringArrayIntersectWithOption({"c"},{"a","b"}) );

    print("\n");

    print( na_getStringArrayIntersectWithOption({"b","a","c"},{"a","b"}) );

    print("\n");

    print( na_getStringArrayIntersectWithOption({"a"},{}) );

    print("\n");

    print( na_getStringArrayIntersectWithOption({},{"b"}) );

    print("\n");

}

/**is attribute on this control of required type

@result int 1 if attribute is of required type 0 otherwise

@param string $control animator control

@param string $attr animator attribute

@param string $type type ex: bool or enum

*/

global proc int

na_isAttributeOfThisType(string $control, string $attr, string $type )

{

    na_isAttributeOfThisType_assert($control,$attr,$type);

    int $result = 0;

    string $plug = "";

    $plug = $control+"."+$attr;

    string $attrType = "";

    $attrType = `addAttr -query -at $plug`;

   

    //note strcmp return negative numbers sometimes

    if( `strcmp $attrType $type` == 0 ){

        $result = 1;

    }

    else{ $result = 0; }

   

    return $result;

}

/**

@note

supported types "bool","enum","double","double3","long"

@param string $control animator control

@param string $attr animator attribute

@param string $type type ex: bool or enum

*/

global proc

na_isAttributeOfThisType_assert(string $control, string $attr, string $type )

{

    string $plug = "";

    $plug = $control+"."+$attr;

    if( `objExists $plug` == 0 ){error($plug+"--not found");}

    string $supportedType[] = {"bool","enum","double","double3","long"};

    int $isSupported = 0;

    $isSupported = na_isOption({$type},$supportedType,1);

    if( $isSupported == 0 ){error($type+"--not supported");}

}

/**return 1 if intersection found of one or more arg in option list

@param $arg -- what checking

@param $option -- avaliable options

@param $isAll -- if its 0 checks at least one otherwise checks all

@see na_getStringArrayIntersectWithOption

*/

global proc int

na_isOption(string $arg[], string $option[], int $isAll)

{

    int $result = 0;

    string $intersectResult[] = {};

    $intersectResult = na_getStringArrayIntersectWithOption($arg, $option);

    if($isAll == 0){

       

        if( size($intersectResult) > 0 ){

            $result = 1;

        }

       

    }else{

        //default

        if( size($intersectResult) == size($arg) ){

            $result = 1;

        }

    }

   

    return $result;

}

global proc

na_isOption_unitTest()

{

    print( na_isOption({"a","c"},{"a","b"},0) );

    print("\n");

    print( na_isOption({"a","c"},{"a","b"},1) );

    print("\n");

    print( na_isOption({"c"},{"a","b"},0) );

    print("\n");

    print( na_isOption({"b","a","c"},{"a","b"},0) );

    print("\n");

    print( na_isOption({"b","a","c"},{"a","b"},1) );

    print("\n");

    print( na_isOption({"a"},{},0) );

    print("\n");

    print( na_isOption({},{"b"},0) );

    print("\n");

}

/**is argument a curve

@param string $arg -- node ex:(joint, or curve ..)

*/

global proc int na_isCurve(string $arg){

    int $isCurve = 0;

   

    int $isTransform = 0;

    int $isChildCurve = 0;

    //is it a transform

    int $isTransform = na_isType($arg,"transform");

   

    //does it have at least one child of type nurbsCurve

    int $isChildCurve = na_hasChildOfType($arg,"nurbsCurve");

   

    if( ($isTransform == 1) && ($isChildCurve == 1) ){ $isCurve = 1; }

   

    return $isCurve;

}

/**return 1 if argument is of type

@param string $arg -- a node

@param string $type -- a node type ex: ("nurbsCurve")

*/

global proc int na_isType(string $arg, string $type)

{

    int $isType = 0;

    string $curType = `objectType $arg`;

   

    //is this of input type

    if(`strcmp $curType $type` == 0){$isType = 1;}

   

    return $isType;

}

/**return 1 if argument is of type

@param string $arg -- a node

@param string $plug -- a plug

@param string $type -- a node type ex: ("nurbsCurve")

*/

global proc int na_isAttrType(string $object, string $plug, string $type)

{

    int $isType = 0;

    string $objectAndPlug = "";

    $objectAndPlug = ($object+"."+$plug);

    if( `objExists $objectAndPlug` == 1){

        string $curType = `addAttr -query -at $objectAndPlug`;

        //is this of input type

        if(`strcmp $curType $type` == 0){$isType = 1;}

    }

    return $isType;

}

/**

@bug no error checking

*/

global proc int

na_isAttrTypeSupportedArray(string $object, string $attr[], string $supported[])

{

    int $result = 1;

    int $isType = 0;

    string $objectAndPlug = "";

    string $plug = "";

    for( $i = 0 ; $i < size($attr); $i++ )

    {

        $plug = $attr[$i];

        $objectAndPlug= ($object+"."+$plug);

        if( `objExists $objectAndPlug` == 1){

            $isType = na_isAttrTypeSupported($object,$plug,$supported);

            if($isType == 0){

                $result = 0;

                break;

            }

        }

    }

    return $result;

}

global proc int na_isAttrTypeSupported(string $object, string $plug, string $supported[])

{

    int $isType = 0;

    string $objectAndPlug = ($object+"."+$plug);

    if( `objExists $objectAndPlug` == 1){

        //if its supported dont continue looping

        for($i = 0; $i < size($supported); $i++)

        {

            //is the type of this supported

            $isType = na_isAttrType($object,$plug,$supported[$i]);

            if($isType == 1){ break;}

        }

    }

    return $isType;

}

/**return 1 if argument is of any type in supported array

@param string list $arg -- nodes to check

@param string list $type -- a node type array ex: ({"nurbsCurve","joint"})

@see na_isTypeSupported

@bug no error checking

*/

global proc int

na_isTypeSupportedArray(string $arg[], string $supported[])

{

    int $result = 1;

    int $isType = 0;

    for( $i = 0 ; $i < size($arg); $i++ )

    {

        $isType = na_isTypeSupported($arg[$i],$supported);

        if($isType == 0){

            $result = 0;

            break;

        }

    }

    return $result;

}

/**return 1 if argument is of any type in supported array

@param string $arg -- a node

@param string list $type -- a node type array ex: ({"nurbsCurve","joint"})

@see na_isType

*/

global proc int na_isTypeSupported(string $arg, string $supported[])

{

    int $isType = 0;

   

    //if its supported dont continue looping

    for($i = 0; $i < size($supported); $i++)

    {

        //is the type of this supported

        $isType = na_isType($arg,$supported[$i]);

        if($isType == 1){ break;}

    }

    return $isType;

}

/**get subset of $arg that is of any type in $supported

@result string list subset of $arg that is of any type in $supported

@param string list $arg

@param string list $supported types that should be returned

*/

global proc string[]

na_getSupported(string $arg[], string $supported[])

{

    string $noFormatType[] = {};

    string $type = "";

    string $formatArg="";

   

    string $result[] = {};

    $noFormatType = stringArrayCatenate({""},$supported);

    $type = stringArrayToString($noFormatType," -type ");

    $formatArg = stringArrayToString($arg," ");

    $result = `eval( "ls "+$type+" "+$formatArg )`;

    return $result;

}

/**return 1 if argument has at least one child of type

@param $arg -- a node

@param $type -- a node type ex: ("nurbsCurve")

*/

global proc int na_hasChildOfType(string $arg, string $type)

{

    int $hasChildOfType = 0;

    string $childrenCurveShape[] = {};

    $childrenCurveShape = `listRelatives -children -type $type $arg`;

    //here is where the atleast shows up

    //if changed to equal 1 say must have exactly one child of that type

    if(size($childrenCurveShape) > 0){$hasChildOfType = 1;}

   

    return $hasChildOfType;

}

/**given string array of node and node type return array for name first occurence of node type

@param string array of node ex: [blendNode, tweakNode, shapeNode]

@param string node type ex: tweak, blendShape

*/

global proc string[]

getFirstHasNodeType(string $nodeArray[], string $nodeType)

{

    string $result[];

    int $i= 0;

    string $tempType;//store node type of loop element,cleared on every step

    //loop nodes of input

   

    for ($i=0;$i< size($nodeArray); $i++)

    {

        $tempType = `nodeType $nodeArray[$i]`;

        //if found matching node return it

        if( $tempType == $nodeType  )

        {

            $result[0] = $nodeArray[$i];

            break;

        }

    }

   

    return $result;

}

/**return vertices given a polygon selection

@param string polygon name

@note often user may need to user vertices from a polygon selection

this script helps with returning that

@result string list all vertices of polygon

*/

global proc string[]

getVtxFromPoly(string $poly)

{

    string $result[];

    string $sel[] = `ls -sl`;

   

    //will be altering user scene

    //with constaint command

    //so added check necessary

   

    if(`objExists $poly`){

        select -cl;

        select -r $poly;

        polySelectConstraint -type 0x0001 -shell true -m 3;//mode no constraint used

        string $expanded[] = `ls -sl`;

        $result = `filterExpand -sm 31 -expand true`;

        polySelectConstraint -shell false;

       

        select -cl;

        select -r $sel;

    }

    else

    {

        warning("no poly exists");

    }

    return $result;

}

////get poly name given any poly component

/*supports any component vtx,face,edge,vFace ..

*/

global proc string[] getPolyFromComponent(string $component)

{

    string $result[];

   

    string $parts[];

    tokenize($component,".",$parts);

    $result[0] = $parts[0];  

   

    return $result;

}

/**get shapes anywhere in dag for this node

*/

global proc string[] na_getShapeDag(string $node)

{

    na_getShapeDag_assert($node);

   

    string $result[];

    $result = `ls -type shape -dag $node`;    

    return $result;

}

/**assert

*/

global proc

na_getShapeDag_assert(string $node)

{

    //existence check

     if(`objExists  $node` == 0){ error("Sorry, Cannot find--"+$node); }

}

/**

@pre assumes empty scene

*/

global proc

na_getShapeDag_unitTest()

{

    polyCube -w 1 -h 1 -d 1 -sx 1 -sy 1 -sz 1 -ax 0 1 0 -cuv 4 -ch 1;

    print( na_getShapeDag("pCube1") );

}

/**return plug from nodes

@param string $node[]  objects

@result string list input converted to plugs ex,  joint1.translateX, joint2.translateX ...

@pre no checks on existence

*/

global proc string[]

na_getPlug( string $node[], string $attribute )

{

    string $drivenPlusAttrArray[] = {};

    string $attr = "";

    $attr = $attribute;

   

    for($j = 0; $j < size($node); $j++)

    {

        $drivenPlusAttrArray[size($drivenPlusAttrArray)] = ($node[$j])+"."+$attr;

    }

   

    return $drivenPlusAttrArray;

   

}

/**return plug from single node uses each attribute

@param string $node  single object

@result string list input converted to plugs ex,  joint1.translateX, joint1.translateY ...

@pre no checks on existence

@bug no assert

@see na_getPlug

*/

global proc string[]

na_getPlugByAttributeArray( string $node, string $attribute[] )

{

    string $drivenPlusAttrArray[] = {};

    string $attr[] = {};

    $attr = $attribute;

   

 

    for($j = 0; $j < size($attribute); $j++)

    {

        $drivenPlusAttrArray[size($drivenPlusAttrArray)] = $node+"."+($attr[$j]);

    }

   

    return $drivenPlusAttrArray;  

}

/**given vertex return its skin cluster name

@param string a vertex name ex: afsf.vtx[5]

*/

global proc string[]

getSkinClusterGivenVertex(string $_vtx)

{

    string $sel[] = `ls -sl`;

    string $skinClusterName[];

   

    //if vertex is on scene

    if( `objExists $_vtx` == 1 )

    {

       

       

        //temporary fix to builtin error if no skin cluster on vertex

        //get the shape of this vertex check if shape has greater 2 items if it does we

        //assume can call skincluster cmd

        string $poly[] = getPolyFromComponent($_vtx);

        if(size($poly) > 0 ){

           

            select -clear;

            select -r $poly;

            pickWalk -d down;

            string $shapePoly[] = `ls -sl`;

            string $targets[] = `listConnections -s false -d true -c true $shapePoly[0]`;

            if( size($targets) > 2 ){

               

                string $jointArray[] = `skinCluster -q -inf $_vtx`;//get joint names using skin cluster node

               

                //if the vertex had multiple influences use the first one

                string $firstJoint = $jointArray[0];

                string $destinationList[] = `listConnections -s false -d true -c true $firstJoint`;

               

                $skinClusterName = getFirstHasNodeType($destinationList, "skinCluster");

            }

           

        }

       

        //restore user selection

        select -r $sel;  

       

    }

   

    return $skinClusterName;

}

/**give me the first index where input value matches input search array (returns int array)

@param $value           string  what to look for

@param $searchArray     string array

@note it behaves alot like pythons list.index(value) function, where search array acts as list

@note it returns empty array if no index match found

*/

global proc int[]

naIndex(string $value, string $searchArray[] )

{

    int $result[];

   

    //loop search array

    for($i=0; $i < size($searchArray); $i++){

        //if match found store index and break out of loop

        int $matchValue = strcmp($value, $searchArray[$i]);

        if(  $matchValue == 0 )

        {

            $result[0] = $i;

            break;

        }

    }

   

    return $result;

}

/////given cluster name and vertex selection, return subset of vertex selection that also has cluster name

/*

in making user selections in skinning

theres a chance that multiple skin clusters may be involved

this make sures a set of vertices all come from the same skin cluster

returning empty means none of vertex has the input argument skincluster name

*/

global proc

string[]

getVertexWithThisSkinCluster(string $_skinClusterName, string $_vtxArray[])

{

    string $result[];

    string $skinClusterName = $_skinClusterName;

    string $vtxArray[] = $_vtxArray;

   

    int $i=0;

   

    //loop vertices

    for($i=0; $i < size($vtxArray); $i++)

    {

        //should we return this vertex

        string $candidateVertex = $vtxArray[$i];

        string $skinClusterNameArray[] = getSkinClusterGivenVertex($candidateVertex );

        //vertex has same skin cluster

        if(  `strcmp $skinClusterNameArray[0] $skinClusterName` == 0 )

        {

            //so save it

            $result[size($result)] = $candidateVertex ;

        }

    }

   

    return $result;

}

/**get list all curves

@result string list all curves

*/

global proc string[] getListAllCurves(){

    string $allCurves[];

   

    //get all curve non transform

    string $allNonTransformCurves[] = getListAllObjectsByType(9);

   

    //get all curve transform

    //  some curves become a transform when an object is parented to it, like a joint parented to a curve

    string $allTransformCurves[] = transformsWithAChildShapeOfType("nurbsCurve");

   

    //glue names together

    appendStringArray($allCurves, $allNonTransformCurves, size($allNonTransformCurves) ) ;

    appendStringArray($allCurves, $allTransformCurves, size($allTransformCurves) ) ;

   

    return $allCurves;

}

/**get transforms that has a specific type of child

@param $type ex: nurbsCurve  say want all transform that have a nurbsCurve as a child

@result string list of transforms meeting input criteria

*/

global proc string[] transformsWithAChildShapeOfType(string $type){

   

    string $transformCurves[];

     //get list of all transform nodes

    string $allPossibleChild[] = getListAllObjectsByNodeType($type);

    //get all parents for each child that are a transform

    string $allParentOfChildType[] = `listRelatives -parent -type transform $allPossibleChild`;

   

    $transformCurves = `stringArrayRemoveDuplicates($allParentOfChildType)`;

    return $transformCurves;

}

/**get list all polygon mesh

@result string list all polygons in scene

*/

global proc string[] getListAllPolygonMesh(){

    string $allPolygonMesh[] = getListAllObjectsByType(12);

    return $allPolygonMesh;

}

/**get list all nurbs surfaces

@result string list all nurbs surfaces in scene

*/

global proc string[] getListAllNurbs(){

    string $allNurbs[] = getListAllObjectsByType(10);

    return $allNurbs;

}

/**get enum items given a transform and enum attribute

@param string $object object with attribute

@param string $attr enum attribute

@note errors if not recognized enum type

@see na_assertObjectExist, na_assertSizeEqualArg

*/

global proc string[]

na_getEnumList( string $object, string $attr )

{

    string $result[] = {};

   

    na_assertObjectExist( {$object+"."+$attr} );

    string $enumItemArray[] = {};

    $enumItemArray = `attributeQuery -listEnum -node $object $attr`;

    na_assertSizeEqualArg($enumItemArray, 1);

   

    $result = stringToStringArray($enumItemArray[0], ":");

    return $result;

}

/**get string list separating object from plug

@param object and plug ex: cube.translateX

@post {cube, translateX}

*/

global proc string[]

na_getObjectSepPlug( string $objectAndPlug )

{

    string $result[] = {};

   

    na_assertObjectExist( {$objectAndPlug} );

    string $sep[] = {};

    $sep = stringToStringArray($objectAndPlug, ".");

   

    //expecting an object, and a plug

    na_assertSizeEqualArg($sep, 2);

   

    $result = $sep;

    return $result;

}

/**get a list of all created objects by list

@param  a maya name indicates what thing is selected

@result string list of object names

@note    transform   any transform node

@note    joint       any joint

@note    lambert     any material

@note    lambert     any material

@note    nurbsCurve    any curve shape

*/

global proc string[] getListAllObjectsByNodeType(string $type){

   

    string $option[] = {"lambert","transform","joint","displayLayer","nurbsCurve"};

    int $is_type = 0;

   

    if( na_isOption({$type},$option, 1)  == 1 )

        { print(selectSuccessMessage()); }

    else{ error(selectErrorMessage()); }

    string $allObjectOfType[];

    string $allObjectOfType[] = `ls -type $type`;

    return $allObjectOfType;

}

global proc

na_isOption_unitTest()

{

   int $result1 = na_isOption({"translateZ","translateY"},{"translateX","translateY"},1);

    // Result: 0 //

    print($result1+"\n");

   int $result2 = na_isOption({"translateZ","translateY"},{"translateX","translateY"},0);

    // Result: 1 //

    print($result2+"\n");

   

}

/**get a list of all created objects by selection mask

@param selection mask

@note  12  polygons

@note 9   curve

@note 22  locators  

@note 0   ikhandles

@note 10 nurbs

*/

global proc string[] getListAllObjectsByType(int $mask_arg){

int $mask = $mask_arg;

if( ($mask == 12) || ($mask == 9) || ($mask == 22) || ($mask == 0) || ($mask == 10)  ){ print(selectSuccessMessage()); }

else{ exit(selectErrorMessage()); }

//store current selection

string $currentSelection[] = `ls -sl`;

//select every thing on scene

select -cl;

string $allSceneObjects[] = `ls`;

select $allSceneObjects;

//filter selection

string $filtered[] = `filterExpand -selectionMask $mask`;

//remove duplicate names

string $allPolygonObjects[] = stringArrayRemoveDuplicates($filtered);

//restore current selection

select $currentSelection;

return $allPolygonObjects;

}

//get list of all joint objects

//  no arguments needed

global proc string[] getListAllJoints(){

    string $allJoints[] = getListAllObjectsByNodeType("joint");

    return $allJoints;

}

//get list of all lambert materials

//  no arguments needed

global proc string[] getListAllCreatedLambertMaterials(){

   

    string $allLambertMaterial[];

    string $allLambert[] = getListAllObjectsByNodeType("lambert");

   

    //remove first element lambert1

    //first element is not always lambert1

   

    int $i = 0;

    for ($i=0; $i< size($allLambert); $i++)

    {

        if($allLambert[$i] != "lambert1"){

                     $allLambertMaterial[size($allLambertMaterial)] = $allLambert[$i];

             }

    }

   

   

    return $allLambertMaterial;

}

/**get list of all display layers

@results string list of layer names

*/

global proc string[] getListAllCreatedLayers(){

   

    string $allCreatedLayers[];

    string $allLayers[] = getListAllObjectsByNodeType("displayLayer");

   

   

    //remove first element defaultLayer

    //first element is not always defaultLayer

   

    int $i = 0;

    for ($i=0; $i< size($allLayers); $i++)

    {

        if($allLayers[$i] != "defaultLayer"){

                     $allCreatedLayers[size($allCreatedLayers)] = $allLayers[$i];

             }

    }

   

   

    return $allCreatedLayers;

}

/**get list of all material info

@param $mat string list of materials

@result string list correspond to input material and requested type

*/

global proc string []

getListAllMaterialInfo(string $mat[]){

    string $result[];

    $type = "materialInfo";

    $result = getListAllConnectOfName($mat,$type);

    return $result;

}

/**get list of all shading engine

@param $mat string list of materials

@result string list correspond to input material and requested type

*/

global proc string []

getListAllShadingEngine(string $mat[]){

    string $result[];

    $type = "shadingEngine";

    $result = getListAllConnectOfName($mat,$type);

    return $result;

}

/**get list of all things connected to node of given type both input and output

@param $mat string list of any transform: poly,nurb,null

@param $type string  of any connection type

@result string list correspond to input object and requested type

@note only works one level, that is if something is connected to thing connected to this it doesnt check that

*/

global proc string []

getListAllConnectOfName(string $object[],string $type){

    string $result[];

    $result = `listConnections -type $type $object`;

    return $result;

}

/**make all selected nodes in hierarchy's aniamtion curves linear for specified attribute

*/

global proc na_linearCurveSelected( string $attr[] )

{

    string $nodeArray[] = {};

    $nodeArray = `ls -sl`;

    print $nodeArray;

    na_stretchCleanCurve($nodeArray,$attr);

}

/**sets post infinity to linear and make curve linear

@param string list $nodeArray  -- names of nodes

@param string list $attr -- names of attributes whose curve were interested in for each node

@note not sure what happens for a missing attribute on a node

*/

global proc na_stretchCleanCurve(string $nodeArray[], string $attrArray[])

{

    string $temp[] ={};

    $temp = getAttributeAnimCurvesMultipleNode($nodeArray, $attrArray );

    string $curves[] = {};

    $curves = stringArrayRemoveDuplicates($temp);

   

    if(size($curves) > 0){

        //make linear curve

        selectKey -add -k $curves;

        keyTangent -itt linear -ott linear;

       

        //post infinity

        setInfinity -poi linear;

       

        print "changing interpolation of animation curves\n";

    }

   

}

/**get all anim curves for specific input attribute and multiple input node

@param string list $nodeArray -- node names

@param string list $attr -- attributes of which to find anim curves for

@note doesn't work with blend weighted nodes, that is node must directly have the anim curve

*/

global proc string[]

getAttributeAnimCurvesMultipleNode(string $nodeArray[], string $attr[] )

{

    string $result[];

    string $tempResult[] = {};//hold for each node

    string $node ="";    

    for( $i = 0; $i < size($nodeArray); $i++ ){

        $node = $nodeArray[$i];      

        $tempResult = getAttributeAnimCurves($node, $attr );    

        //store anim curve

        $result = stringArrayCatenate($result,$tempResult);

    }

    return $result;

}

/**get all anim curves for specific input attribute and one input node

@param string $node -- node

@param string list $attr -- attributes of which to find anim curves for

*/

global proc string[]

getAttributeAnimCurves(string $node, string $attr[] )

{

    string $result[];

    string $name = "";

    int $is_driverAttr = 0;//does attribute exist

    string $tempResult[] = {};//hold for each node

   

    if(`objExists $node`){

        for($i = 0; $i < size($attr) ; $i++ )

        {

            $is_driverAttr = `attributeExists $attr[$i] $node`;

            //can we access node

            if($is_driverAttr == 1){

                $name = $node+"."+$attr[$i];

                $tempResult = `listConnections -type "animCurve" $name`;

               

                //store anim curve

                $result = stringArrayCatenate($result,$tempResult);

                clear($tempResult);

            }

            else{print("skipping attribute --"+$attr[$i]+"-- was not found\n");

            }

        }

    }

   

    return $result;

}

/**get list of all group objects

@result string list of queried objects

*/

global proc string[] getListAllCreatedGroupObjects(){

   

    string $allGroupObjects[];

    string $allTransform[] = getListAllObjectsByNodeType("transform");

   

    //a group has no shape node as children, check this

    int $i = 0;

    for ($i=0; $i< size($allTransform); $i++)

    {

        if( size(`listRelatives - shapes $allTransform[$i]`) == 0){

                     $allGroupObjects[size($allGroupObjects)] = $allTransform[$i];

             }

    }

   

    return $allGroupObjects;

}

//error messaging

//  no arguments needed

global proc string selectSuccessMessage()

{

    string $message = "returning all objects\n";

    return $message;

}

//error messaging

//  no arguments needed

global proc string selectErrorMessage()

{

    string $message = "cannot return all objects - check argument for selection\n";

    return $message;

}