/////////////////////////////////////////////////////////////////////////////// // // Utility Functions for the Angel Mel Scripts // // angelActor and angelPropPlacer were getting too big, so i took // out "utility" type functions and placed them here.. // ie. File Choosers, etc.. /////////////////////////////////////////////////////////////////////////////// global proc shError ( string $theErrorMessage) { shToolLog ("SH Maya Tool", $theErrorMessage); // shPlayWav ("c:\\share\\sh\\export\\inactive.wav"); string $confirm = `confirmDialog -title "Spy Hunter Tool Error Catcher" -message $theErrorMessage -button "OK"`; } global proc shMessage( string $messageBoxName) { string $confirm = `confirmDialog -title "Spy Hunter Instant Messenger!" -message $messageBoxName -button "OK"`; } global proc string shHashResolve (string $key, string $KeyList[] , string $ValueList[]) { string $oneKey; int $count=0; for ($oneKey in $KeyList) { if ($key == $oneKey) { return $ValueList[$count]; } $count++; } } global proc string shGetShortName(string $object) { string $tokenList[]; int $total= `tokenize $object "|" $tokenList`; string $shortObjectName = $tokenList[$total-1]; $shortObjectName = shChopThePipe ($shortObjectName); return $shortObjectName; } // show all textures which are in use by this file global proc listTextures() { string $nodeList[] = `ls -type file`; string $nodeName; print $nodeList; for ($nodeName in $nodeList) { string $nn = ($nodeName+".fileTextureName"); string $textureFile = `getAttr $nn`; print ($textureFile+" = "+$nodeName+"\n"); } } global proc int shIsActorLocked( string $actorName) { if (shIsActor ($actorName)) { string $isLocked[] = `listAttr -ud -st "locked" $actorName`; if($isLocked[0] == "locked") { int $value = `getAttr ($actorName + ".locked")`; if ($value) { return 1; // locked } else { return 0; // not locked } } else { return 0; // is not locked } } else { shError ("shIsActorLocked : Not even an actor!"); } } //============================================================================= // // if an actor is selected, return the # of actors currently selected; //============================================================================= global proc int shIsActorSelected() { string $selectedActors[] = shGetSelectedActors(); int $totalActorsSelected = `size $selectedActors`; return ($totalActorsSelected); } //============================================================================= // Returns a list of all actors which are selected //============================================================================= global proc string[] shGetSelectedActors() { //===================================================================== // get a list of everything selected //===================================================================== string $objects[] = `ls -sl -type "transform"`; string $thisObj; string $selectedActors[]; if(`size($objects)`) { for($thisObj in $objects) { if (shIsActor( $thisObj)) { $selectedActors[`size $selectedActors`] = $thisObj; } } } return $selectedActors; } global proc string[] shGetAllCurves() { //===================================================================== // get a list of everything selected //===================================================================== string $objects[] = `ls -type "transform"`; string $thisObj; string $selectedCurves[]; if(`size($objects)`) { for($thisObj in $objects) { if (shIsCurve( $thisObj)) { $selectedCurves[`size $selectedCurves`] = $thisObj; } } } return $selectedCurves; } global proc string[] shGetAllLights() { //===================================================================== // get a list of everything selected //===================================================================== string $objects[] = `ls -type "transform"`; string $thisObj; string $selectedLights[]; if(`size($objects)`) { for($thisObj in $objects) { if (shIsLight( $thisObj)) { $selectedLights[`size $selectedLights`] = $thisObj; } } } return $selectedLights; } global proc string[] shGetSelectedLights() { //===================================================================== // get a list of everything selected //===================================================================== string $objects[] = `ls -sl -type "transform"`; string $thisObj; string $selectedLights[]; if(`size($objects)`) { for($thisObj in $objects) { if (shIsLight( $thisObj)) { $selectedLights[`size $selectedLights`] = $thisObj; } } } return $selectedLights; } global proc string[] shGetSelectedCurves() { //===================================================================== // get a list of everything selected //===================================================================== string $objects[] = `ls -sl -type "transform"`; string $thisObj; string $selectedCurves[]; if(`size($objects)`) { for($thisObj in $objects) { if (shIsCurve( $thisObj)) { $selectedCurves[`size $selectedCurves`] = $thisObj; } } } return $selectedCurves; } /////////////////////////////////////////////////////////////////////////////////////////////////////// // // PutComponent // Synopsis: PutComponent; // Return Value: None // // Description: InsertDescription Here... // add an ANGEL COMPONENT to the selected actor // // Requires: useXML.mll // // Version: 1.0 beta // Author: Joe Stinchcomb // Last Revised: 01.10.2002 // global proc attachObjectComponentToActor ( string $objectName, string $groupName, string $componentName) { if (shIsActor( $objectName)) { // good actor print ("Attaching to ("+$objectName+") Group("+$groupName+") Component ("+$componentName+")\n"); string $actorNode; $actorNode = `getAttr ($objectName + ".ActorNode")`; AddComponent ("AngelObjectComponents|"+$groupName+"|"+$componentName) $actorNode; } else { shError ("Cant Attach a component to a non-actor"); return; } } //============================================================================= // Put an angel COMPONENT on all selected Actors //============================================================================= global proc attachObjectComponentToActorOnSelected(string $groupName, string $componentName) { string $actorNode; if (shIsActorSelected()) { string $selection[] = shGetSelectedActors(); for ($s in $selection) { attachObjectComponentToActor ($s, $groupName, $componentName); } select -r $selection; } print "Done Placing Components on Objects\n"; } // put an angel template on the selected objects global proc PutComponents(string $template, string $type) { string $selection[]; string $actorNode; if (shIsActorSelected()) { $selection = shGetSelectedActors(); $actorNode = `getAttr ($selection[0] + ".ActorNode")`; //print("template: " + $template + " type: " + $type + "\n"); string $componentsToAdd[] = `listRelatives -c ("AngelObjectTemplates|" + $template + "|" + $type)`; for ($component in $componentsToAdd) { //print("component: " + $component + "\n"); AddComponent ("AngelObjectTemplates|" + $template + "|" + $type + "|" + $component) $actorNode; } select -r $selection[0]; } else { shError ("Trying to put a component , but no actors selected"); } } /////////////////////////////////////////////////////////////////////////////////////////////////////// // // UpdateTextFieldGrp // Synopsis: UpdateTextFieldGrp; // Return Value: None // // Description: InsertDescription Here... // // Requires: useXML.mll // // Version: 1.0 beta // Author: Joe Stinchcomb // Last Revised: 01.10.2002 // global proc UpdateTextFieldGrp (string $fieldGrp, string $updateAttribute) { string $value = `textFieldGrp -q -text $fieldGrp`; setAttr $updateAttribute -type "string" $value; } global proc UpdateTextFieldGrpArray (string $control, string $theAttribute, int $index) { // Get the value from the field string $value = `textFieldGrp -q -text $control`; // Get the current value string $attributeValue[] = `getAttr $theAttribute`; // Modify the value $attributeValue[$index] = $value; // Set the new value setAttr $theAttribute -type $attributeValue; } /////////////////////////////////////////////////////////////////////////////////////////////////////// // // UpdateTextFieldButtonGrp // Synopsis: UpdateTextFieldButtonGrp; // Return Value: None // // Description: InsertDescription Here... // // Requires: useXML.mll // // Version: 1.0 beta // Author: Joe Stinchcomb // Last Revised: 01.10.2002 // global proc UpdateTextFieldButtonGrp (string $fieldGrp, string $updateAttribute) { string $value = `textFieldButtonGrp -q -text $fieldGrp`; print ("Trying to update Attribute ("+$updateAttribute+")\n"); setAttr $updateAttribute -type "string" $value; } /////////////////////////////////////////////////////////////////////////////////////////////////////// // // UpdateDoubleFieldGrp // Synopsis: UpdateTextFieldGrp; // Return Value: None // // Description: InsertDescription Here... // // Requires: useXML.mll // // Version: 1.0 beta // Author: Joe Stinchcomb // Last Revised: 01.10.2002 // global proc UpdateDoubleFieldGrp (string $uiElement, string $updateAttribute) { float $value = `floatFieldGrp -q -v1 $uiElement`; setAttr $updateAttribute $value; } global proc UpdateIntFieldGrp (string $uiElement, string $updateAttribute) { int $value = `intFieldGrp -q -v1 $uiElement`; setAttr $updateAttribute $value; } /////////////////////////////////////////////////////////////////////////////////////////////////////// // // UpdateTextScrollList // Synopsis: UpdateTextScrollList; // Return Value: None // // Description: InsertDescription Here... // // Requires: useXML.mll // // Version: 1.0 beta // Author: Joe Stinchcomb // Last Revised: 01.10.2002 // global proc UpdateTextScrollList (string $scrollListField){ global string $sys_root; string $selectionToRestore[] = `textScrollList -q -si $scrollListField`; textScrollList -e -ra $scrollListField; string $dirs; string $dirTokens[]; string $dirThis; string $stripped; int $bSize; chdir ($sys_root + "/shop/layout"); //if(`pwd` == "c://shop/layout"){ $dirs = `system ("ls")`; //print ("\n\n" + $dirs + "\n\n"); tokenize $dirs "\n" $dirTokens; for($dirThis in $dirTokens){ textScrollList -e -append (`strip $dirThis`) $scrollListField; } //} if((`filetest -d ($sys_root + "/shop/layout/" + $selectionToRestore[0])`) && ($selectionToRestore[0] != "")){ textScrollList -e -si $selectionToRestore[0] $scrollListField; } } //============================================================================= // Idle Handler // //============================================================================= int $sh_IdleChange=0; int $sh_ResetFlag=0; int $sh_IdleScriptJob=-1; global proc sh_IdleHandler() { global int $sh_IdleChange; global int $sh_ResetFlag; if ($sh_IdleChange<=0) { $sh_IdleChange=0; // return 0; } $sh_IdleChange--; if ($sh_IdleChange > 0) return; if ($sh_ResetFlag > 0 ) { print "Reverting Back to Select Mode -h!\n"; selectMode -h; $sh_ResetFlag--; // killHandlers( "sh_IdleHandler"); // return 1; } // return 0; } /////////////////////////////////////////////////////////////////////////////////////////////////////// // // Search to see if a scriptJob is installed, if // it is, return its scriptJob Number // global proc int isHandlerInstalled( string $HandlerName) { $cmd = "scriptJob -listJobs"; string $s[] = eval ($cmd); $SizeOfArray = size ($s); for ($x = 0; $x < $SizeOfArray; $x++) { $find = "*"+$HandlerName+"*"; if (gmatch( $s[$x], $find )) { $HookUp=1; $num = match ("[0-9]*[0-9]*[0-9]*[0-9]*[0-9]:", $s[$x]); $n1 = match ("[0-9]*[0-9]*[0-9]*[0-9]*[0-9]", $num); // chop off : // print ("Found Handler " + $s[$x] + "\n"); return ($n1); // return the Handler Number } } return -1; // return the scriptJob if found, else -1 if not found } /////////////////////////////////////////////////////////////////////////////////////////////////////// // // Search for all handlers named HandlerName, and kill em. // global proc int killHandlers( string $HandlerName ) { $result = 0; $cmd = "scriptJob -listJobs"; string $s[] = eval ($cmd); $SizeOfArray = size ($s); for ($x = 0; $x < $SizeOfArray; $x++) { $find = "*"+$HandlerName+"*"; if (gmatch( $s[$x], $find )) { $num = match ("[0-9]*[0-9]*[0-9]*[0-9]*[0-9]:", $s[$x]); $n1 = match ("[0-9]*[0-9]*[0-9]*[0-9]*[0-9]", $num); // chop off : $cmd = "scriptJob -kill " + $n1; eval ($cmd); print ($cmd + "\n"); $result++; // a handler has been killed } } return $result; // return total handlers killed } //============================================================================= // After you do a file -f -new, it sets the SelectMode to -o (object), // we dont want this, we want -h... it seems to set the mode in a handler // so this hack sets the mode in the idle handler.. //============================================================================= global int $sh_selectModeFlag = 0; global proc int sh_ResetAfterNew() { global int $sh_selectModeFlag; $sh_selectModeFlag=2; // 2 becuase NEW calls resetSelectModeMask twice return 1; global int $sh_IdleChange; global int $sh_ResetFlag; //============================================================= // If an old handler is already installed, kill it //============================================================= if (isHandlerInstalled("sh_IdleHandler") != -1) { killHandlers ("sh_IdleHandler"); } $sh_IdleChange+=5; // wait x frames, then do the change.. //============================================================= // Install our special idle handler //============================================================= print "Hooking up Idle Handler\n"; $cmd = "scriptJob -idleEvent \"sh_IdleHandler\""; $sh_IdleScriptJob = eval ($cmd); $sh_ResetFlag=1; return 1; } global proc string browseForFileSimple( string $extension , string $title) { global string $sys_root; global string $currentFolder; global int $browseSuccess; string $mayaFolder = "c:\\share\\sh\\art\\"; string $tokenList[]; int $tokenCount = `tokenize $extension "|" $tokenList`; string $newExt=""; string $token; for ($token in $tokenList) { if ($newExt=="") { $newExt = ("*."+$token); } else { $newExt = ($newExt + ";*."+$token); } } print ("New Extension = ("+$newExt+")\n"); $result = `fileDialog -dm ($newExt)` ; return $result; } global proc browseForFile( string $fieldToChange, string $theAttribute, string $extension , string $title) { global string $sys_root; global string $currentFolder; global int $browseSuccess; string $mayaFolder = "c:\\share\\sh\\art\\"; string $tokenList[]; int $tokenCount = `tokenize $extension "|" $tokenList`; string $newExt=""; string $token; for ($token in $tokenList) { if ($newExt=="") { $newExt = ("*."+$token); } else { $newExt = ($newExt + ";*."+$token); } } print ("New Extension = ("+$newExt+")\n"); $result = `fileDialog -dm ($newExt)` ; textFieldButtonGrp -e -text $result $fieldToChange; UpdateTextFieldButtonGrp $fieldToChange $theAttribute; } // Browse for XML file and load it into the scene as a sub xml.. global proc browseForXML(string $fieldToChange, string $theAttribute) { global string $sys_root; global string $currentFolder; global int $browseSuccess; browseForFolder( $currentFolder, "Choose directory to load sub-tree..." ); if( $browseSuccess ) { // For now just give the name of the file // // Get the name of the directory string $folder = $currentFolder; ///// Do some checking ///////////////// if(!`filetest -d $folder`){ confirmDialog -title "Error" -message ("Could not find a sub-level to load in: " + $folder ) -button "OK"; return; } string $actorFiles[] = `getFileList -fld $folder -fs "*.xml"`; if(!`size($actorFiles)`) { confirmDialog -title "Error" -message ("Could not find a sub-level to load in: " + $folder ) -button "OK"; return; } /////////////////////////////////////// // Only store the part of the path below "lvl" string $tokens[]; print ($currentFolder + "\n"); int $numtokens = `tokenize $currentFolder "/" $tokens`; string $result = ($tokens[$numtokens-2] + "/" + $tokens[$numtokens-1]); if ( `size $result` ) { textFieldButtonGrp -e -text $result $fieldToChange; UpdateTextFieldButtonGrp $fieldToChange $theAttribute; // Get the name of the node to add to $numtokens = `tokenize $theAttribute "." $tokens`; string $node = $tokens[0]; print ("Field to change: " + $theAttribute + "\n"); $node = getFullPath ($node); // Process this layout ProcessLayout ($sys_root + "/assets/lvl/" + $result + "/") $node 1; // Load any sub trees under this layout // LoadXMLSubTrees $node 0; // Jan14, RS: I took this line out, // because ProcessLayout actually // recursivly loads all subtrees... // this function isnt needed.. } else { string $confirm = `confirmDialog -title "Error: Load sub-tree" -message ("That is not a valid layout to load.") -button "OK"`; } } } global proc UpdateCheckBox(string $fieldToChange, string $toUpdate){ int $value = `checkBoxGrp -q -v1 $fieldToChange`; //print $toUpdate; setAttr $toUpdate $value; } //============================================================================= // GUI UpdateReferenceFields for pulldowns.. //============================================================================= global proc UpdateRefField(string $fieldToChange, string $toUpdate) { //print("FieldToChange: " + $fieldToChange + "\n"); string $value = `optionMenuGrp -q -v $fieldToChange`; //print("Value: " + $value + "\n"); //print $toUpdate; setAttr $toUpdate -type "string" $value; } global proc DeleteNodeFromGUI_Array( string $ScrollListControl, string $FullAttributeName) { // Sort List and Delete in Reverse ORDER>. highest to lowest print "Delete Node From GUI Array\n"; int $selectedIndexItems[] = `textScrollList -q -selectIndexedItem $ScrollListControl`; int $itemNumber; for ($itemNumber in $selectedIndexItems) { //print ("Killed Index ("+$itemNumber+")\n"); textScrollList -e -removeIndexedItem $itemNumber $ScrollListControl; } // find the indices which are selected // delete them from the sharrray // rebuild the scrolllistctonrol // set the attibute node } global proc AddNodeFromGUI_Array( string $ScrollListControl, string $FullAttributeName, string $newElement) { print "Add Node From GUI Array\n"; int $selectedIndexItems[] = `textScrollList -q -selectIndexedItem $ScrollListControl`; int $itemNumber; for ($itemNumber in $selectedIndexItems) { } } global proc MoveNodeUpFromGUI_Array( string $ScrollListControl, string $FullAttributeName) { print "Move Node UP\n"; int $selectedItems[] = `textScrollList -q -selectIndexedItem $ScrollListControl`; int $itemNumber; for ($itemNumber in $selectedItems) { // get the string of itemNumber-1.. // print ("Item Number Of Orig = "+$itemNumber+")\n"); int $parentItemNum = $itemNumber-1; if ($parentItemNum > 0) { textScrollList -e -deselectAll $ScrollListControl; textScrollList -e -selectIndexedItem $parentItemNum $ScrollListControl; int $parentIndices[] = `textScrollList -q -selectIndexedItem $ScrollListControl`; string $parentStrings[] = `textScrollList -q -selectItem $ScrollListControl`; int $parentIndex = $parentIndices[0]; string $parentItem = $parentStrings[0]; print ("Parent Item = ("+$parentIndex+") = ("+$parentItem+")\n"); textScrollList -e -appendPosition ($itemNumber+1) ($parentItem+"asd") $ScrollListControl; textScrollList -e -removeIndexedItem $parentIndex $ScrollListControl; } //print ("Selected ("+$item+")\n"); } } global proc MoveNodeDownFromGUI_Array( string $ScrollListControl, string $FullAttributeName) { print "Move Node Down\n"; int $selectedItems[] = `textScrollList -q -selectIndexedItem $ScrollListControl`; int $itemNumber; for ($itemNumber in $selectedItems) { // get the string of itemNumber-1.. // print ("Item Number Of Orig = "+$itemNumber+")\n"); int $parentItemNum = $itemNumber+1; if ($parentItemNum > 0) { textScrollList -e -deselectAll $ScrollListControl; textScrollList -e -selectIndexedItem $itemNumber $ScrollListControl; int $itemIndices[] = `textScrollList -q -selectIndexedItem $ScrollListControl`; string $parentStrings[] = `textScrollList -q -selectItem $ScrollListControl`; int $itemIndex = $itemIndices[0]; string $itemName = $parentStrings[0]; textScrollList -e -removeIndexedItem $itemIndex $ScrollListControl; textScrollList -e -appendPosition ($itemIndex+1) ($itemName+" asd") $ScrollListControl; } //print ("Selected ("+$item+")\n"); } } // update the node attribute, based on the GUI Pulldown... global proc UpdateRefFieldArray( string $GUIControlName, string $FullAttributeName, int $arrayIndex) { // Read the Value in the GUI Control string $value = `optionMenuGrp -q -v $GUIControlName`; //print("Value: " + $value + "\n"); //print $toUpdate; // and put it in the Nodes' Attribute // read the attribute from the Node (which is an shARray) // convert it to a Maya Array // modify the index... // convert it back to a shArray // store it.. string $myArray = `getAttr $FullAttributeName`; print ("{{{{{{ original array = ("+$myArray+")\n"); string $a[] = shArray_sh2Maya( $myArray ); print ("{{{{{{ setting index ("+$arrayIndex+") to ("+$value+")\n"); $a[$arrayIndex] = $value; $myArray = shArray_Maya2sh($a); print ("{{{{{{ out array = ("+$myArray+")\n"); setAttr $FullAttributeName -type "string" $myArray; } global proc UpdateRefFieldArray_old(string $control, string $theAttribute, int $index){ //print("FieldToChange: " + $fieldToChange + "\n"); // Get the value from the menu string $value = `optionMenuGrp -q -v $control`; // Get the current value string $attributeValue[] = `getAttr $theAttribute`; // Modify the value $attributeValue[$index] = $value; //print("Value: " + $value + "\n"); //print $toUpdate; // Set the new value setAttr $theAttribute -type $attributeValue; } global proc EnableButtons(string $component, int $mode){ string $buttonLoc = ("propPlacementWindow|tabLayout2|editAttributesPanel|aoiMiddleColumn|aoiMiddleFormLayout|aoiMiddleTabLayout|" + $component); string $buttonLoc2 = ("propPlacementWindow|tabLayout2|editAttributesPanel|aoiMiddleColumn|aoiMiddleFormLayout|aoiMiddleTabLayout2|" + $component); //print("Before enable\n"); string $buttons[]; if ( `rowColumnLayout -q -ex $buttonLoc` ) { $buttons = `rowColumnLayout -q -ca $buttonLoc`; for($thisButton in $buttons){ button -e -en $mode ($buttonLoc + "|" + $thisButton); } } else { $buttons = `rowColumnLayout -q -ca $buttonLoc2`; for($thisButton in $buttons){ button -e -en $mode ($buttonLoc2 + "|" + $thisButton); } } //print("After enable\n"); } global proc playBork(){ system ("c:\\Qplayer.exe \"c:\\bork.wav\""); } //============================================================================= // Get Current Working Directory //============================================================================= global proc string getCWD() { string $mayaFolder = `workspace -q -dir`; return $mayaFolder; } //============================================================================= // Set Current Working Directory //============================================================================= global proc setCWD( string $directoryName) { // do some error checking, to see if this directory actually exists! workspace -dir $directoryName; } /////////////////////////////////////////////////////////////////////////////////////////////////////// // // writeSceneReferenceFilePlus // Synopsis: writeSceneReferenceFile; // Return Value: None // // Description: Writes out a file that contains a list of all references in the layout. // // Requires: useXML.mll // // Version: 1.0 beta // Author: Joe Stinchcomb // Last Revised: 01.10.2002 // global proc writeSceneReferenceFilePlus () { string $filename = `getSceneName`; string $obj; string $theoutput[]; string $assetPath = ("C:/o/asset/lvl/" + $filename); if(!`filetest -d $assetPath`) { sysFile -md $assetPath; } int $outFile; string $fullpath = ($assetPath + "/static.refs"); if ( `file -q -ex $fullpath` ){ if ( `filetest -w $fullpath ` ) { $outFile = (`fopen $fullpath "w"`); } else{ confirmDialog -t "WARNING!" -b "OK" -m ("File " + $fullpath + " is not writable, can not continue." ); return; } } else { $outFile = (`fopen $fullpath "w"`); } string $allRefs[] = `file -q -r`; string $indRefs; for ( $indRefs in $allRefs ) { string $fileBase = basename($indRefs, ""); string $associatedNodes[] = `reference -f $fileBase -q -n`; string $obj = $associatedNodes[0]; string $backlotName = getAttr ($obj + ".BacklotName"); fprint $outFile ($backlotName + " " + $indRefs + "\n"); } fflush $outFile; fclose $outFile; } /////////////////////////////////////////////////////////////////////////////////////////////////////// // // writeInstanceFile // Synopsis: writeInstanceFile; // Return Value: None // // Description: Writes a text file that contains a list of all the instanced nodes in the scene. // // Requires: useXML.mll // // Version: 1.0 beta // Author: Joe Stinchcomb // Last Revised: 01.10.2002 // global proc writeInstanceFile () { string $filename = `getSceneName`; string $obj; string $theoutput[]; string $assetPath = ("C:/o/asset/lvl/" + $filename); if(!`filetest -d $assetPath`) { sysFile -md $assetPath; } //get all instance nodes $theoutput = `ls -typ "transform"`; int $outFile; string $fullpath = ($assetPath + "/static.inst"); if ( `file -q -ex $fullpath` ){ if ( `filetest -w $fullpath ` ) { $outFile = (`fopen $fullpath "w"`); } else{ confirmDialog -t "WARNING!" -b "OK" -m ("File " + $fullpath + " is not writable, can not continue." ); return; } } else { $outFile = (`fopen $fullpath "w"`); } for ( $obj in $theoutput ){ if ( !`reference -q -inr $obj` ) { $mytemp = `listAttr -ud -st "AngelInst" $obj`; if ( `size $mytemp` ) { string $bName = `getAttr ($obj + ".BacklotName")`; string $nodepath[]; $nodepath = `pickWalk -d "down" $obj`; fprint $outFile ($nodepath[0] + " " + $bName + "\n"); } } } fflush $outFile; fclose $outFile; } /////////////////////////////////////////////////////////////////////////////////////////////////////// // // writelocsFile // Synopsis: writelocsFile; // Return Value: None // // Description: Writes a text file that contains a list of all the positions, orientations and // scales of all the instanced nodes in the scene. // // Requires: useXML.mll // // Version: 1.0 beta // Author: Joe Stinchcomb // Last Revised: 01.10.2002 // global proc writelocsFile() { string $filename = `getSceneName`; string $assetPath = ("C:/o/asset/lvl/" + $filename); if(!`filetest -d $assetPath`) { sysFile -md $assetPath; } string $fullpath = ($assetPath + "/static.locs"); int $outFile; if ( `file -q -ex $fullpath` ) { if ( `filetest -w $fullpath ` ) { $outFile = (`fopen $fullpath "w"`); } else { confirmDialog -t "WARNING!" -b "OK" -m ("File " + $fullpath + " is not writable, can not continue." ); return; } } else { $outFile = (`fopen $fullpath "w"`); } string $obj; string $theoutput[]; //get all transform nodes $theoutput = `ls -typ "transform"`; fprint $outFile (`size $theoutput` + "\n"); int $numNodesWritten = 0; string $mytemp[]; for ( $obj in $theoutput ) { if ( !`reference -q -inr $obj` ) { $mytemp= `listAttr -ud -st "AngelInst" $obj`; if ( `size $mytemp` ) { $numNodesWritten++; fprint $outFile ($obj + "\n"); float $values[3]; $values = `getAttr ($obj + ".translate")`; fprint $outFile ($values[0] + " " + $values[1] + " " + $values[2] + "\n"); $values = `getAttr ($obj + ".rotate")`; fprint $outFile ($values[0] + " " + $values[1] + " " + $values[2] + "\n"); $values = `getAttr ($obj + ".scale")`; fprint $outFile ($values[0] + " " + $values[1] + " " + $values[2] + "\n"); //doattrs ( 0, $obj, $outFile ); fprint $outFile "\n"; } } } fflush $outFile; frewind $outFile; fprint $outFile ($numNodesWritten + "\n"); fflush $outFile; fclose $outFile; } /////////////////////////////////////////////////////////////////////////////////////////////////////// // // saveLayoutFile // Synopsis: saveLayoutFile; // Return Value: None // // Description: Writes a reference file, an instance file and a locs file. // // Requires: useXML.mll // // Version: 1.0 beta // Author: Joe Stinchcomb // Last Revised: 01.10.2002 // global proc int saveLayoutFile() { writeSceneReferenceFilePlus(); writeInstanceFile(); writelocsFile(); return 1; } /////////////////////////////////////////////////////////////////////////////////////////////////////// // // loadLayoutFile // Synopsis: loadLayoutFile; // Return Value: None // // Description: Loads a layout file. * Old system no longer used. // // Requires: useXML.mll // // Version: 1.0 beta // Author: Joe Stinchcomb // Last Revised: 01.10.2002 // global proc int loadLayoutFile() { readasciiInst(); return 1; } /////////////////////////////////////////////////////////////////////////////////////////////////////// // // readasciiRefs // Synopsis: readasciiRefs; // Return Value: None // // Description: Reads in an loads references based on the .refs file. // // Requires: useXML.mll // // Version: 1.0 beta // Author: Joe Stinchcomb // Last Revised: 01.10.2002 // global proc readasciiRefs() { string $filename = `getSceneName`; string $refFile = ("C:/o/asset/lvl/" + $filename + "/static.refs"); $inFile = (`fopen $refFile "r"`); string $line = `fgetline $inFile`; while ( `size $line`) { string $tokens[]; $lineLen = `size $line`; tokenizeList ($line, $tokens); string $fileToRef = $tokens[1]; string $backlotName = $tokens[0]; file -r $fileToRef; $refs = `reference -f $fileToRef -q -n`; select $refs[0]; addAttr -ln "AngelRef" -at bool $refs[0]; addAttr -ln BacklotName -dt "string"; setAttr -type "string" ($refs[0] + ".BacklotName") $backlotName; //setAttr ($refs[0] + ".AngelRef") 1; // Added by Joe: Sets the default value to true. parent $refs[0] hider; $line = `fgetline $inFile`; } fclose $inFile; } /////////////////////////////////////////////////////////////////////////////////////////////////////// // // readasciiInst // Synopsis: readasciiInst; // Return Value: None // // Description: Reads in an loads an instance file. // // Requires: useXML.mll // // Version: 1.0 beta // Author: Joe Stinchcomb // Last Revised: 01.10.2002 // global proc readasciiInst() { string $sceneName = `getSceneName`; //create the node that will hide the references string $itExists[]; $itExists = `ls hider`; if ( !`size $itExists[0]` ) { createNode "locator" -n "hidershape"; select hidershape; pickWalk -d "up"; rename `ls -sl` "hider"; hide hider; } // reference the necessary files readasciiRefs(); // instance files. string $instFile = ("C:/o/asset/lvl/" + $sceneName + "/static.inst"); $inFile = (`fopen $instFile "r"`); string $line = `fgetline $inFile`; int $index=0; while ( `size $line`) { string $uberTokens[]; tokenize ($line, " ", $uberTokens); //print $uberTokens[0]; string $tokens[]; int $num = `tokenize $uberTokens[0] "|" $tokens`; //$lineLen = `size $tokens[1]`; $lineLen = `size $tokens[1]`; string $toInstance = $tokens[1]; //`substring $tokens[1] 1 ($lineLen-1)`; select -r $toInstance; pickWalk -d up; string $transformNode[] = `ls -sl -type transform`; string $backlotName = getAttr ($transformNode[0] + ".BacklotName"); select -r $toInstance; instance -n $tokens[0]; select $tokens[0]; parent -w $tokens[0]; $mytemp = `listAttr -ud -st "AngelInst" $tokens[0]`; if ( !`size $mytemp` ) { addAttr -at bool -ln "AngelInst"; //setAttr ($tokens[0] + ".AngelInst") 1; //Added by Joe: Sets the default value to true. } $mytemp = `listAttr -ud -st "AngelRef" $tokens[0]`; if ( `size $mytemp` ) { deleteAttr ($tokens[0] + ".AngelRef"); } $mytemp = `listAttr -ud -st "BacklotName" $tokens[0]`; if ( !`size $mytemp` ) { addAttr -ln BacklotName -dt "string"; setAttr -type "string" ($tokens[0] + ".BacklotName") $backlotName; } $line = `fgetline $inFile`; } fclose $inFile; // Now move everything readasciiLocs (); } /////////////////////////////////////////////////////////////////////////////////////////////////////// // // readasciiLocs // Synopsis: readasciiLocs; // Return Value: None // // Description: Reads in and loads a locs file. // // Requires: useXML.mll // // Version: 1.0 beta // Author: Joe Stinchcomb // Last Revised: 01.10.2002 // global proc readasciiLocs() { string $filename = `getSceneName`; string $locsFile = ("C:/o/asset/lvl/" + $filename + "/static.locs"); int $inFile = (`fopen $locsFile "r"`); int $index; int $numNodes; $numNodes = `fgetword $inFile`; //print ($numNodes + " nodes" ); for ( $index = 0; $index < $numNodes; $index++ ) { // select object string $s = `fgetword $inFile`; if ( `objExists $s` ) { select -r $s; } else { return; } float $f[3]; // translate, rotate, scale object $f[0] = `fgetword $inFile`; $f[1] = `fgetword $inFile`; $f[2] = `fgetword $inFile`; move -a $f[0] $f[1] $f[2]; $f[0] = `fgetword $inFile`; $f[1] = `fgetword $inFile`; $f[2] = `fgetword $inFile`; rotate -a $f[0] $f[1] $f[2]; $f[0] = `fgetword $inFile`; $f[1] = `fgetword $inFile`; $f[2] = `fgetword $inFile`; scale -a $f[0] $f[1] $f[2]; }// for numNodes fclose $inFile; } /////////////////////////////////////////////////////////////////////////////////////////////////////// // // getSceneName // Synopsis: getSceneName; // Return Value: String // // Description: Returns the name of the current Maya scene. // // Requires: useXML.mll // // Version: 1.0 beta // Author: Joe Stinchcomb // Last Revised: 01.10.2002 // global proc string getSceneName () { string $scenePath = `file -q -sn`; string $nameTokens[]; int $numTokens = `tokenize $scenePath "/" $nameTokens`; string $name = $nameTokens[$numTokens - 1]; string $buffer[]; int $nameParts = `tokenize $name "." $buffer`; string $sceneName = $buffer[0]; return $sceneName; } /////////////////////////////////////////////////////////////////////////////////////////////////////// // // LaunchLayout // Synopsis: LaunchLayout; // Return Value: None // // Description: Select a LEVEL Layout and RUN it! // // Requires: useXML.mll // // Version: 1.0 beta // Author: Joe Stinchcomb // Last Revised: 01.10.2002 // global proc int LaunchLayout() { global string $currentLayout; global string $currentFolder; global int $browseSuccess; browseForFolder( $currentFolder, "Choose directory to launch layout..." ); if( $browseSuccess ) { string $buffer[]; int $numTokens = tokenize($currentFolder, "/", $buffer); print ("num tokens = " + $numTokens); print ("1) " + $buffer[$numTokens-1]); print ("2) " + $buffer[$numTokens-2]); print ("Current Folder = (" + $currentFolder + ")\n"); string $xmlFile = $currentFolder + $buffer[$numTokens-1] + ".xml"; print ("XML FILE = (" + $xmlFile + ")\n"); runGame($xmlFile); } return 0; } global proc shToolLog ( string $toolName, string $message) { string $cmd = "perl c:\\Share\\Sh\\Export\\ToolLog.pl \""+$toolName+"\" \""+$message+"\""; string $result = system( $cmd ); print( $result + "\n" ); } global proc shPlayWav( string $fullWavFileName) { string $cmd = "perl c:\\Share\\Sh\\Export\\playWav.pl "+ $fullWavFileName; string $result = system( $cmd ); print( $result + "\n" ); } global proc runGame(string $xmlFileName) { //===================================================================== // Launch Game //===================================================================== shToolLog ("SH Maya Tool", ("Exporting ("+$xmlFileName+")")); string $cmd = "perl c:\\Share\\Sh\\Export\\launchFromXML.pl "+ $xmlFileName; print("CMD (" + $cmd + ")\n"); string $result = system( $cmd ); print( $result + "\n" ); } // Returns the # of objects selected in MAYA // returns 0 if nothing is selected global proc int isSomethingSelected() { string $selectedItems[] = `ls -sl -l`; int $numSelected = `size ( $selectedItems )`; return $numSelected; } global proc int totalObjectsSelected() { return (isSomethingSelected()); } //============================================================================= // returns a list of all possible ACTOR NAMES // note: object_ seems to be prepended infront // of the name //============================================================================= global proc string[] shGetActorList() { string $actorNameList[]; if ( `objExists ("AngelObjectData")` ) { $actorNameList = `listRelatives -c ("AngelObjectData")`; } return $actorNameList; } //============================================================================= // returns a list of all possible GROUP NAMES //============================================================================= global proc string[] shGetGroupList() { // Information on Group Names are taken from COMPONENTS.xml // which are the "Class Definitons" string $groupNameList[]; if ( `objExists ("AngelObjectComponents")` ) { $groupNameList = `listRelatives -c ("AngelObjectComponents")`; } return $groupNameList; } //============================================================================= // returns a list of all possible COMPONENT NAMES, // under a given GROUP NAME //============================================================================= global proc string[] shGetComponentList( string $groupName) { // Information on Component Names are taken from COMPONENTS.xml // which are the "Class Definitons" string $componentNameList[]; if ( `objExists ("AngelObjectComponents|" + $groupName)` ) { $componentNameList = `listRelatives -c ("AngelObjectComponents|" + $groupName)`; } return $componentNameList; } //============================================================================= // returns a list of all possible COMPONENT NAMES, // under a given GROUP NAME, //============================================================================= global proc string[] shGetTemplateComponentList( string $groupName) { string $finalTemplateList[]; string $templateNameList[]; if ( `objExists ("AngelComponentTemplates|" + $groupName)` ) { $templateNameList = `listRelatives -c ("AngelComponentTemplates|" + $groupName)`; } string $compName; for ($compName in $templateNameList) { string $templateList[]; $templateList = shGetTemplateTemplateList($groupName, $compName); // append templateList to master string $tName; for ($tName in $templateList) { $finalTemplateList[`size $finalTemplateList`] = $tName; } } return $finalTemplateList; } //============================================================================= // returns a list of all possible TEMPLATE NAMES, // under a given GROUP NAME, // and under a given COMPONENT NAME //============================================================================= global proc string[] shGetTemplateTemplateList( string $groupName, string $componentName) { string $templateNameList[]; if ( `objExists ("AngelComponentTemplates|" + $groupName + "|" + $componentName)` ) { $templateNameList = `listRelatives -c ("AngelComponentTemplates|" + $groupName + "|" + $componentName)`; } return $templateNameList; } //============================================================================= // returns a list of all possible ATTRIBUTE NAMES, // under a given GROUP NAME, // under a given COMPONENT NAME // under a given TEMPLATE NAME //============================================================================= global proc string[] shGetAttributeList( string $groupName, string $componentName, string $templateName) { string $out[]; string $obj = "AngelComponentTemplates|"+ $groupName+ "|" + $componentName + "|" + $templateName; if ( `objExists ($obj)`) { $out = `listAttr -ud -v ($obj)`; } return $out; } // Given a GROUP Name, return a list of all actors with this group attached to it. global proc string[] shGetActorsWithGroup( string $groupNameIn) { string $out[]; string $actorList[] = shGetActorList(); string $actor; for ($actor in $actorList) { //============================================================= // Get a list of components hooked up to // this actor.. //============================================================= string $component; string $componentList[] = `listRelatives -c ("AngelObjectData|" + $actor)`; //============================================================= // Jam thru all the components, and extract // their GROUP name, if the Group Name, matches // the groupname we want, add it to the list //============================================================= for ($component in $componentList) { string $groupName = `getAttr ("AngelObjectData|" + $actor + "|" + $component + ".UIGroupName")`; if ( $groupName == $groupNameIn ) { // Add this actor to the list $out[`size $out`] = $actor; break; } } } return $out; } //============================================================================= // given a GROUP and COMPONENT, return all actors who have these // components.. //============================================================================= global proc string[] shGetActorsWithGroupAndComponent( string $groupNameIn, string $componentNameIn) { string $out[]; if ($groupNameIn == "Volume") { if ($componentNameIn == "CullRoom") { print ("Recurse Actor List = ("+$groupNameIn+") ("+$componentNameIn+")\n"); $out = shGetActorsWithGroupAndComponentRecurse("", $groupNameIn, $componentNameIn); return $out; } } string $actorList[] = shGetActorList(); string $actor; for ($actor in $actorList) { //print($actor + "\n"); string $component; string $componentList[] = shGetComponentsOnActor( $actor); for ($component in $componentList) { if ($component == $componentNameIn) { string $groupName = shGetGroupOnActorComponent( $actor, $component); if ( $groupNameIn == $groupName ) { //===================================== // The GROUP and COMPONENT names // match, so add the actor to // the list //===================================== $out[`size $out`] = $actor; break; } } } } return $out; } global proc string[] shGetActorsWithGroupAndComponentRecurse(string $parent, string $groupNameIn, string $componentNameIn) { string $out[]; if ($parent == "") { $parent = "AngelObjectData"; } string $actorList[]; print ("RECURSE down parent ("+$parent+")\n"); $actorList = `listRelatives -c $parent`; string $actor; for ($actor in $actorList) { string $fullActor = ($parent+"|"+$actor); // print(" "+$fullActor + "------ fullname\n"); string $component; string $componentList[] = `listRelatives -c ($fullActor)`; for ($component in $componentList) { if ($component == $componentNameIn) { // string $groupName = shGetGroupOnActorComponent( $actor, $component); // if ( $groupNameIn == $groupName ) // { //===================================== // The GROUP and COMPONENT names // match, so add the actor to // the list //===================================== print (" adding actor ("+$fullActor+")\n"); $out[`size $out`] = $fullActor; break; // } } if ($component == "XMLTreeComponent") { string $newOut[]; // string $newParent = ($parent+"|"+$fullActor+"|"+$component); string $newParent = ($fullActor+"|"+$component); $newOut = shGetActorsWithGroupAndComponentRecurse($newParent , $groupNameIn, $componentNameIn); // add $newOut to $out string $act; for ($act in $newOut) { $out[`size $out`] = ($act); } } } } return $out; } //============================================================================= // make sure the directory path is valid // ie. No Spaces, No Wierd Special Chars // returns 0 = Invalid Path // 1 = Valid Path //============================================================================= global proc int shIsDirPathValid ( string $dirPath) { //===================================================================== // ensure no spaces //===================================================================== if (`gmatch $dirPath "* *"`) { return 0; // INVALID } //===================================================================== // ensure only valid characters //===================================================================== string $s = `match "[A-Za-z0-9_/\\:.]*" $dirPath`; if ($s != $dirPath) { return 0; // INVALID } return 1; // VALID } //============================================================================= // make sure the Group/Comp/Template/Actor name is valid // ie. No Spaces, No Wierd Special Chars // returns 0 = Invalid name // 1 = Valid name //============================================================================= global proc int shIsNameValid (string $name) { //===================================================================== // ensure no spaces //===================================================================== if (`gmatch $name "* *"`) { return 0; // INVALID } //===================================================================== // ensure only valid characters //===================================================================== string $s = `match "[A-Za-z0-9_]*" $name`; if ($s != $name) { return 0; // INVALID } return 1; // VALID } //============================================================================= // Given a name, check all template names, component names, // group names, and actor names to make sure it doesnt exist //============================================================================= // 0 = doesnt exist // other = exists;; global proc int shIsNameExist( string $name, int $showDialogErrorMessage) { int $hit_count=0; string $error_message=""; //===================================================================== // check for spaces or wierd characters //===================================================================== $name = tolower ($name); string $groupName; string $groupList[] = shGetGroupList(); for ($groupName in $groupList) { //print ("Checking Group "+$groupName+")\n"); string $groupNameLower = tolower ($groupName); if ($name == $groupNameLower) { $hit_count++; $error_message = ("GExists in GROUP("+$groupName+")\n"); } string $componentName; string $componentList[] = shGetComponentList ($groupName); for ($componentName in $componentList) { string $componentNameLower = tolower( $componentName ); //print ("Checking Comp ("+$componentName+")\n"); if ($name == $componentNameLower) { $hit_count++; $error_message= ("CExists in ("+$groupName+"/"+$componentName+")\n"); } string $templateName; string $templateList[] = shGetTemplateTemplateList($groupName, $componentName); for ($templateName in $templateList) { $templateNameLower = tolower ($templateName); if ($name == $templateNameLower) { $hit_count++; $error_message= ("TExists in ("+$groupName+"/"+$componentName+"/"+$templateName+")\n"); } } } } // Jam thru all the actors in the world, and see if they have the same name... string $nameObject = "object_"+$name; $nameObject = tolower ($nameObject); string $actorList[] = shGetActorList(); string $actor; for ($actor in $actorList) { $actor = tolower ($actor); if ($actor == $name) { $hit_count++; $error_message = ("Actor has same name"); } if ($actor == $nameObject) { $hit_count++; $error_message = ("Actor has same name"); } } if ($showDialogErrorMessage>0) { if ($hit_count>0) { $error_message = $error_message + "("+$hit_count+")"; confirmDialog -title "Name Already Exists" -message $error_message -button "OK"; return 1; //MATCH was found! } } print ("HitCount = "+$hit_count); return $hit_count; // Name does not exist } //============================================================================= // given an object name, determine if its an actor //============================================================================= global proc int shIsActor( string $actorName) { string $attlist[] = `listAttr -ud $actorName`; for ($att in $attlist) { if ($att == "ActorNode") { return 1; // yes, we have bananas! } } return 0 ; // no , its not an actor } global proc int shIsCurve( string $curveName) { string $rel[] = `listRelatives $curveName`; string $curve; for ($curve in $rel) { string $fatName = ($curveName+"|"+$curve); //print ("Curve = ("+$fatName+")\n"); string $ntype = `nodeType $fatName`; if ($ntype == "nurbsCurve") { return 1; // yes, we have bananas! } } return 0; } //============================================================================= // given a list of objects (usually from all selected), kill everything // but actors, and return the list //============================================================================= global proc string[] shKeepOnlyActors( string $objectList[]) { string $current; string $newCurrentList[]; for ($current in $objectList) { if (shIsActor( $current)) { // we found an actor, add it to the list $newCurrentList[ `size $newCurrentList`] = $current; } } return $newCurrentList; } //============================================================================= // if the name start with a |, chop it off //============================================================================= global proc string shChopThePipe ( string $objectName) { string $first; $first = `substring $objectName 1 1`; if ($first == "|") { int $ss = `size $objectName`; $objectName = `substring $objectName 2 $ss`; } return $objectName; } // if the name begins with "object_" chop it off global proc string shChopObject( string $objectName) { if (gmatch ($objectName, "object_*")) { int $ss = `size $objectName`; $objectName = `substring $objectName 8 $ss`; } return $objectName; } //============================================================================= //============================================================================= // // Actor "Class" Functions... // //============================================================================= //============================================================================= //============================================================================= // given an Actor and Component Name, return the GROUP name associated // with the Component. //============================================================================= global proc string shGetGroupOnActorComponent( string $actorName, string $componentIn) { string $groupName = `getAttr ("AngelObjectData|" + $actorName + "|" + $componentIn + ".UIGroupName")`; return $groupName; } //============================================================================= // Given an actor, kick out any groups that are // attached to it.. //============================================================================= global proc string[] shGetGroupsOnActor ( string $actorName ) { string $out[]; string $componentList[]; $componentList = shGetComponentsOnActor( $actorName); // we go backwards..from the component to find out its group string $component; for ($component in $componentList) { string $groupName = `getAttr ("AngelObjectData|" + $actorName + "|" + $component + ".UIGroupName")`; $out[`size $out`] = $groupName; } return ($out); } //============================================================================= // Given an actor name (with object_), return all the // components hooked on to it.. //============================================================================= global proc string[] shGetComponentsOnActor ( string $actorName) { string $out[]; string $componentList[]; $componentList = `listRelatives -c ("AngelObjectData|"+$actorName)`; $out = $componentList; return ($out); } global proc showAttributes() { string $selectList[] = `ls - sl`; string $item; for ($item in $selectList) { showAttributesOnOne ( $item); } } global proc showAttributesOnOne( string $node) { print ("===================================================\n"); print (" Show Attributes on Node\n"); print ("===================================================\n"); print("NODE = ("+$node+")---------------------------\n"); string $attList[] = `listAttr -ud $node`; string $att; for ($att in $attList) { string $aName = ($node+"."+$att); string $typename = `getAttr -typ $aName`; // check the attributes TYPE to see if its COMPOUND, before getting it.. if ( $typename == "TdataCompound" ) { int $i = 0; string $attributeValue[]; while (1) { string $attr = ($node + "." + $att + "_" + $i); string $name = ($att + "_" + $i); string $value = ("value" + $i); //print ("Attr = ("+$attr+")\n"); //print ("Name = ("+$name+")\n"); //print ("Value= ("+$value+")\n"); //print ("Checking to see if attribute ("+$name+") exists on node ("+$node+")\n"); if ( `attributeExists $name $node` ) { //print "Found!\n"; $atVal = `getAttr -sl $attr`; // useXML setattribute $value $atVal; //print ("AT VALUE = ("+$atVal+")\n"); print (" ("+$attr+") = ("+$atVal+")\n"); //print ("Setting ("+$value+") = ("+$atVal+")\n"); } else { break; } $i++; } } else { print ("Type = ("+$typename+")\n"); if (!( ($typename == "double3") || ($typename == "matrix") )) { string $value = `getAttr $aName`; print ("("+$aName+") = ("+$value+")\n"); } } } } global proc shJoint_LockScale() { string $jointList[] = `ls -type joint`; string $joint; for ($joint in $jointList) { //print ("Joint = ("+$joint+")\n"); int $result; $result = `getAttr -lock ($joint+".sx")`; if (!$result) { print ("Locking Scale X ("+$joint+")\n"); setAttr -lock true ($joint+".sx"); } $result = `getAttr -lock ($joint+".sy")`; if (!$result) { print ("Locking Scale Y ("+$joint+")\n"); setAttr -lock true ($joint+".sy"); } $result = `getAttr -lock ($joint+".sz")`; if (!$result) { print ("Locking Scale Z ("+$joint+")\n"); setAttr -lock true ($joint+".sz"); } } // return $jointList; } // Object creation time test global proc CreateObjectTest() { for ($x=0; $x< 500; $x++) { polyCube -w 1 -h 1 -d 1 -sx 1 -sy 1 -sz 1 -ax 0 1 0 -tx 1 -ch 1 -name "aaaaaaaaaaaaaaaa"; } } // Turn off UNDO feature // UNDO QUeue to 0 global proc LoadTestRepeat( int $a) { shUtil_showMemory(); FastModeOn(); print "-------------- REPEAT TEST ---------------\n"; float $maxTime = 0; for ($loop =0; $loop < $a ; $loop++) { $maxTime += LoadTest(); } print ("==== TOTAL TIME = "+$maxTime+"\n"); shUtil_showMemory(); print "-------------- CLEAR IT OUT ---------------\n"; $startTime = `timerX`; file -f -new -force; $totalTime = `timerX -startTime $startTime`; print ("Total Time For a NEW : "+$totalTime+"\n"); print "-------------- REPEAT END ---------------\n"; shUtil_showMemory(); FastModeOff(); } global proc float LoadTest() { $startTime = `timerX`; //===================================================================== // Stick your code call below //===================================================================== CreateObjectTest(); $totalTime = `timerX -startTime $startTime`; print ("Total Time: "+$totalTime+"\n"); return $totalTime; } global proc FastModeOn() { print ("_+_+_+_+_+_+_+_+_+_+ FAST MODE ON _+_+_+_+_+_+_+_+_+_+_\n"); undoInfo -state off; } global proc FastModeOff() { print ("_+_+_+_+_+_+_+_+_+_+ FAST MODE OFF _+_+_+_+_+_+_+_+_+_+_\n"); undoInfo -state on; } global proc int shUtil_findActorWithPropName( string $actorName, string $propNameRef) { string $actorList[] = shActorObject_getAll(); string $actor; for ($actor in $actorList) { $actor = shChopThePipe ($actor); string $propName = shActorObject_getPropName ( $actor); if ($propNameRef == ($propName+":root")) { // found it!! return 1; } } return 0; } // jam thru all the actors, and get the list of all // references its using. global proc string[] shUtil_getActorRefNames() { progressWindow -title "Removing Unused References" -progress 0 -status "Removing unused References" -isInterruptable false; string $actorList[] = shActorObject_getAll(); string $refNameList[]; string $actor; int $actorTotal = `size $actorList`; print ("I found ("+$actorTotal+") actors in this world\n"); float $percent=0; int $count=0; for ($actor in $actorList) { $count++; $percent = ($count/$actorTotal)*100; string $message = ("Searching ("+$count+") of ("+$actorTotal+")\n"); progressWindow -edit -progress $percent -status $message; string $propName = shActorObject_getPropName ( $actor); $refNameList[ `size $refNameList`] = ($propName+":root"); } progressWindow -e -ep; // kill duplicates.. return $refNameList; } // return a list of unused references... global proc string[] shUtil_findUnusedReferences() { string $refList[] = shActorObject_getAllReferences(); string $goodRefs[]; string $badRefs[]; string $actor, $ref; // get all the actors.. and make a list of all the references its using.. string $actorRefList[] = shUtil_getActorRefNames(); // delete all the elements in actorRefList which are in refList;; // if any elements are in refList..those are the ones which // are not used.. // print $actorRefList; // print "===============\n"; // print $refList; string $unusedRefs[] = stringArrayRemove ( $actorRefList, $refList); return $unusedRefs; } global proc shUtil_showMemory() { float $freeMemory[] = `memory -freeMemory`; float $heapMemory[] = `memory -heapMemory`; float $physicalMemory[] = `memory -physicalMemory`; print ("Free Memory = ("+$freeMemory[0]+")\n"); print ("Heap Memory = ("+$heapMemory[0]+")\n"); print ("Physical Memory = ("+$physicalMemory[0]+")\n"); string $s[] = `memory -summary`; print $s; } global proc shUtil_duplicateSelected() { string $objList[] = `ls -sl`; // get selected list for ($oneObj in $objList) { print ("Duplicating Obj ("+$oneObj+")\n"); duplicate -rr $oneObj; } print ("Done...\n"); } global proc shUtil_email(string $emailTO, string $emailFROM, string $emailSUBJECT, string $emailBODY) { }