Message 1 of 2
Help fixing a script_srbMultiCache?

Not applicable
04-15-2010
03:37 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello I found this script in creative crash "srbMultiCache", it caches multiples objects (selection), you are able to export / import caches, for some reason the import option does not work, I can't figure out why?
Help much appreciated.
I'm using Maya 2011 but I'm geting the same error with 2009 and 2010
here the code:
//////////////////////////////////////////////////////////////////// //CREATE THE GLOBAL PROCEDURE---
global proc srbMultiCache() {
//USER INTERFACE---
if (`window -exists srbMultiCacheWin`) deleteUI srbMultiCacheWin;
window
-title "Cache multiple objects"
-rtf 1
-maximizeButton 0
srbMultiCacheWin;
columnLayout -adj 1;
textFieldButtonGrp
-label "Cache directory:"
-text "Enter cache file directory path (d:/data/sphere)..."
-buttonLabel "Browse"
-buttonCommand "srbFileBrowser"
dirPathTFG;
intSliderGrp -field 1 -label "Start Frame:"
-minValue -0 -maxValue 100
-fieldMinValue -1000 -fieldMaxValue 1000
-value ( `playbackOptions -q -min ` )
startFrameISG;
intSliderGrp -field 1 -label "End Frame:"
-minValue -0 -maxValue 100
-fieldMinValue -1000-fieldMaxValue 1000
-value ( `playbackOptions -q -max ` )
endFrameISG;
textFieldGrp
-label "Substitute reference name:"
-text ""
substituteTFG;
button -l "Export" -c "srbMultiCacheExportProc";
button -l "Import" -c "srbMultiCacheImportProc";
separator;
text -al left " This tool create a cache file for each selected Objects";
separator;
showWindow srbMultiCacheWin;
}
//CREATE THE MAIN PROCEDURE---
///////////////////////////////////////////////////////////////////
//Export Cache procedure
global proc srbMultiCacheExportProc () {
//DECLARE AND STORE SOME VARIABLES---
global string $gMainProgressBar;
string $dirPath = `textFieldGrp -query -text dirPathTFG`;
int $startFrameVal = `intSliderGrp -query -value startFrameISG`;
int $endFrameVal = `intSliderGrp -query -value endFrameISG`;
string $replaceName = `textFieldGrp -query -text substituteTFG`;
string $sel[] = `ls -sl`;
int $sizeSel = `size($sel)`;
//CREATE AND EDIT THE CUSTOM PROGRESSBAR ---
progressBar
-edit
-beginProgress
-isInterruptable true
-status "Exporting caches for selected objects...."
-maxValue ($sizeSel)
$gMainProgressBar;
if ($sizeSel == 0)
{
warning "Please select at least one geometry to export cache...";
}
else
{
for ($obj in $sel)
{
if(`progressBar -query -isCancelled $gMainProgressBar`)
{break;
print "Exporting cache file cancelled by user...\n";
}
progressBar
-edit
-step 1
$gMainProgressBar;
string $newName = `substitute $replaceName $obj ("")`;
string $newDirPath = ($dirPath + "/" + $newName )
select -r $obj;
doCreateGeometryCache 4 { "3", $startFrameVal, $endFrameVal, "OneFilePerFrame", "1", $newDirPath,"0","","0", "add", "0", "1", "1","0","0" } ;
}
//END PROGRESS BAR---
progressBar -edit
-endProgress
$gMainProgressBar;
print "SRB - Multiple Cache v0.3 has completed exporting geometry cache for selected objects...";
}
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//Import Cache Procedure
global proc srbMultiCacheImportProc ()
{
string $dirPath = `textFieldGrp -query -text dirPathTFG`;
int $startFrameVal = `intSliderGrp -query -value startFrameISG`;
int $endFrameVal = `intSliderGrp -query -value endFrameISG`;
string $replaceName = `textFieldGrp -query -text substituteTFG`;
string $sel[] = `ls -sl`;
int $sizeSel = `size($sel)`;
if ($sizeSel == 0)
{
warning "Please select at least one geometry to import cache...";
}
else
{
//MAIN LOOP---
for ($obj in $sel)
{
string $colon = ":";
string $newName = `substitute $replaceName $obj ("")`;
string $cacheName = `substitute $colon $obj("_")`;
string $newDirPath = ($dirPath + "/" + $newName + "/" + $cacheName + "Shape.xml")
select -r $obj;
ImportCacheFile $newDirPath "xml";
}
print "SRB - Multiple Cache v0.3 has completed importing geometry cache for selected objects...";
}
}
global proc srbFileBrowser ()
{
fileBrowserDialog -mode 4 -fc "srbUpdateDirectory" -an "Pick your cache file directory:";
return;
}
global proc srbUpdateDirectory (string $path, string $mode)
{
string $bases[] = `ls -sl`;
float $size = `size $bases`;
string $base = $bases;
select -ado;
string $before[] = `ls -sl`;
textFieldButtonGrp -edit -text $path dirPathTFG;
}
//IMPORTANT PIECE OF CODE---
source doImportCacheFile.mel;
global proc int
ImportCacheFile(string $fileName, string $fileType)
{
string $geometries[];
return doImportCacheFile($fileName, $fileType,$geometries,{})
}
//THE END---
srbMultiCache;
Help much appreciated.
I'm using Maya 2011 but I'm geting the same error with 2009 and 2010
here the code:
//////////////////////////////////////////////////////////////////// //CREATE THE GLOBAL PROCEDURE---
global proc srbMultiCache() {
//USER INTERFACE---
if (`window -exists srbMultiCacheWin`) deleteUI srbMultiCacheWin;
window
-title "Cache multiple objects"
-rtf 1
-maximizeButton 0
srbMultiCacheWin;
columnLayout -adj 1;
textFieldButtonGrp
-label "Cache directory:"
-text "Enter cache file directory path (d:/data/sphere)..."
-buttonLabel "Browse"
-buttonCommand "srbFileBrowser"
dirPathTFG;
intSliderGrp -field 1 -label "Start Frame:"
-minValue -0 -maxValue 100
-fieldMinValue -1000 -fieldMaxValue 1000
-value ( `playbackOptions -q -min ` )
startFrameISG;
intSliderGrp -field 1 -label "End Frame:"
-minValue -0 -maxValue 100
-fieldMinValue -1000-fieldMaxValue 1000
-value ( `playbackOptions -q -max ` )
endFrameISG;
textFieldGrp
-label "Substitute reference name:"
-text ""
substituteTFG;
button -l "Export" -c "srbMultiCacheExportProc";
button -l "Import" -c "srbMultiCacheImportProc";
separator;
text -al left " This tool create a cache file for each selected Objects";
separator;
showWindow srbMultiCacheWin;
}
//CREATE THE MAIN PROCEDURE---
///////////////////////////////////////////////////////////////////
//Export Cache procedure
global proc srbMultiCacheExportProc () {
//DECLARE AND STORE SOME VARIABLES---
global string $gMainProgressBar;
string $dirPath = `textFieldGrp -query -text dirPathTFG`;
int $startFrameVal = `intSliderGrp -query -value startFrameISG`;
int $endFrameVal = `intSliderGrp -query -value endFrameISG`;
string $replaceName = `textFieldGrp -query -text substituteTFG`;
string $sel[] = `ls -sl`;
int $sizeSel = `size($sel)`;
//CREATE AND EDIT THE CUSTOM PROGRESSBAR ---
progressBar
-edit
-beginProgress
-isInterruptable true
-status "Exporting caches for selected objects...."
-maxValue ($sizeSel)
$gMainProgressBar;
if ($sizeSel == 0)
{
warning "Please select at least one geometry to export cache...";
}
else
{
for ($obj in $sel)
{
if(`progressBar -query -isCancelled $gMainProgressBar`)
{break;
print "Exporting cache file cancelled by user...\n";
}
progressBar
-edit
-step 1
$gMainProgressBar;
string $newName = `substitute $replaceName $obj ("")`;
string $newDirPath = ($dirPath + "/" + $newName )
select -r $obj;
doCreateGeometryCache 4 { "3", $startFrameVal, $endFrameVal, "OneFilePerFrame", "1", $newDirPath,"0","","0", "add", "0", "1", "1","0","0" } ;
}
//END PROGRESS BAR---
progressBar -edit
-endProgress
$gMainProgressBar;
print "SRB - Multiple Cache v0.3 has completed exporting geometry cache for selected objects...";
}
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//Import Cache Procedure
global proc srbMultiCacheImportProc ()
{
string $dirPath = `textFieldGrp -query -text dirPathTFG`;
int $startFrameVal = `intSliderGrp -query -value startFrameISG`;
int $endFrameVal = `intSliderGrp -query -value endFrameISG`;
string $replaceName = `textFieldGrp -query -text substituteTFG`;
string $sel[] = `ls -sl`;
int $sizeSel = `size($sel)`;
if ($sizeSel == 0)
{
warning "Please select at least one geometry to import cache...";
}
else
{
//MAIN LOOP---
for ($obj in $sel)
{
string $colon = ":";
string $newName = `substitute $replaceName $obj ("")`;
string $cacheName = `substitute $colon $obj("_")`;
string $newDirPath = ($dirPath + "/" + $newName + "/" + $cacheName + "Shape.xml")
select -r $obj;
ImportCacheFile $newDirPath "xml";
}
print "SRB - Multiple Cache v0.3 has completed importing geometry cache for selected objects...";
}
}
global proc srbFileBrowser ()
{
fileBrowserDialog -mode 4 -fc "srbUpdateDirectory" -an "Pick your cache file directory:";
return;
}
global proc srbUpdateDirectory (string $path, string $mode)
{
string $bases[] = `ls -sl`;
float $size = `size $bases`;
string $base = $bases;
select -ado;
string $before[] = `ls -sl`;
textFieldButtonGrp -edit -text $path dirPathTFG;
}
//IMPORTANT PIECE OF CODE---
source doImportCacheFile.mel;
global proc int
ImportCacheFile(string $fileName, string $fileType)
{
string $geometries[];
return doImportCacheFile($fileName, $fileType,$geometries,{})
}
//THE END---
srbMultiCache;