RandomDump

From bernie's
Jump to: navigation, search
global string $currentFrameFile;
global int $frameN;
global int $originalFrame;
global string $error;
global int $playblastActive;
global int $tick;
$playblastActive = 0;
$currentFrameFile = $error = "";
$originalFrame = `currentTime -q`;
$frameN = 1;

global proc firePlayblast(){
	firePlayblastUI;
}
proc string findLayout( string $windowUI,string $name )
{//from bryan ewert
  string $controls[] = `lsUI -l -controlLayouts`;
  string $pattern = $windowUI + "*";
  string $layout = "";

  for ( $ui in $controls )
  {
    if ( `gmatch $ui $pattern` )
    {
      string $tokens[];
      int $numTokens = `tokenize $ui "|" $tokens`;
      if ( $numTokens > 1 )
      {
        $layout = $tokens[0] + "|" + $tokens[1];
          string $ca[] = `layout -q -ca $layout`;  
          for ( $c in $ca )
          {      
            return ($layout + "|" + $c);
            break;
          }
        break;
      }
    }
  }
  return false;
}
global proc string pad(float $n){return ($n<1000)? ( ($n<100 )?( ($n<10 )?"000"+$n:"00"+$n ):"0"+$n ) : $n+"";}
global proc string getImagePath(string $extraPath,int $extension){ 
    setAttr "defaultRenderGlobals.outFormatControl" 0;
    setAttr "defaultRenderGlobals.animation" 1;
    setAttr "defaultRenderGlobals.putFrameBeforeExt" 1;
    setAttr "defaultRenderGlobals.extensionPadding" 4;
    string $image = pad(`currentTime -q`);    
    string $tof[] = `renderSettings -gin $image -fp`;
    string $dir = `match "^.*/" $tof[0]`;
    string $filepart = `match "[^/\\]*$" $tof[0]`;
    $filepart = (!$extension)?`match "(.*)[^\.a-z]" $filepart`:$filepart;
    return $dir+$extraPath+$filepart;
}
global  proc string saveFireImage(){
    global string $error;
    global string $currentFrameFile;
//    "+`date -f "MMDD_hhmmss"`+"/
    $filePath = getImagePath("maxwellFirePlayblasts/",0)+".png";
    $mkdir = `sysFile -makeDir (match("^.*/",$filePath))`;
    string $vp = findLayout("MaxwellFIRE","maxwellViewport" );
    if($mkdir && $vp != "0"){
        evalDeferred(`maxwellViewport -e -saveIRImg ($filePath) $vp`);
        $currentFrameFile = $filePath;
    }else{
        $error = "No maxwell FIRE window found";
        firePBrefreshUI;
    }
    return "";
}
global proc firePlayblastUI(){
    global int $frameN;
    int $e = `playbackOptions -query -maxTime`;
    int $s = `playbackOptions -query -minTime`;
    $frameN = $s;
    if (`window -exists playblastFireWindow`) deleteUI playblastFireWindow;
    if (`windowPref -exists playblastFireWindow`) windowPref -remove playblastFireWindow;
    string $window = `window -menuBar true -title "Playblast Fire" playblastFireWindow`;
    string $vp = findLayout("MaxwellFIRE","maxwellViewport" );
    paneLayout -vis ($vp!="0");
    columnLayout -adjustableColumn true;
    progressBar -maxValue 100 -width 300 -vis 1 -en 0 UI_progress;
    textField -text  "'Seconds per frame' includes voxelisation" -en 0 -editable false UI_textfield;
    separator -h 18 -en 0;
    int $timeperframe = `optionVar -q "firePB_secondsperframe"`;
    $timeperframe = ($timeperframe!=0)?$timeperframe:15;
    intFieldGrp -numberOfFields 1 -label "Seconds per frame" -cc "firePBrefreshUI" -value1 $timeperframe UI_timePerF;
    separator -h 12 -en 0;
    intFieldGrp -numberOfFields 1 -label "Start frame" -cc "firePBrefreshUI" -value1 $s UI_startF;
    intFieldGrp -numberOfFields 1 -label "End frame" -cc "firePBrefreshUI" -value1 $e UI_endF;
    intFieldGrp -numberOfFields 1 -label "Frame increment" -cc "firePBrefreshUI" -value1 1 UI_incrF;
    int $firePBlaunchfcheck = (`optionVar -q "firePB_fcheck"`=="yes")?1:0;
    checkBoxGrp -numberOfCheckBoxes 1 -cat 1 "both" 90 -label1 "Launch fcheck" -cc "firePBrefreshUI" -value1 $firePBlaunchfcheck UI_fcheck;
    separator -h 12 -en 0;
    button -label "Playblast!" -command "firePythonThread(0)"  -h 40 UI_playblast;
    separator -h 3 -en 1 -st "none";
    button -label "Explore" -command "firePBOpenSequence(0)" UI_explore;
        separator -h 16 -en 1 -st "none";
    button -label "Close" -command "firePythonThread(1);deleteUI playblastFireWindow ";
        separator -h 5 -en 1 -st "none";
    setParent..;setParent..;
    paneLayout -vis ($vp=="0");
    columnLayout -adjustableColumn true;
    button -label "Launch maxwell FIRE first" -command "firePlayblastUI";
    showWindow $window;
}
global proc firePBTic(int $incr){
	global int $tick;
	global int $frameN;
	

    firePBrefreshUI;
    if(!$incr){
        $tick++;
    }else{
		int $incrF = `intFieldGrp -q -value1 UI_incrF`;
        saveFireImage;
        currentTime -u 1 -e (`currentTime -q`+$incrF);
		if($frameN = `intFieldGrp -q -value1 UI_endF`){
			firePythonThread(1);
		}
		$frameN = `currentTime -q`;
    }
}
global proc firePythonThread(int $kill){
    global int $originalFrame;
    global int $playblastActive;
    global string $error;

     
    python( "import threadProc;from threadProc import Timer;import maya.mel as mm" );
    if(!$kill){
		int $timePerF = `intFieldGrp -q -value1 UI_timePerF`;
        $playblastActive = 1;
        currentTime -u 1 -e (`intFieldGrp -q -value1 UI_startF`);
        python( "def tic():mm.eval('firePBTic(0)')");
        python( "def toc():mm.eval('firePBTic(1)')");
        python( "timerTic = Timer(1, tic, repeat=True);timerTic.start()");
        python( "timerToc = Timer("+$timePerF+", toc, repeat=True);timerToc.start()");
    }else{
		string $vp = findLayout("MaxwellFIRE","maxwellViewport" );
		maxwellViewport -e -irPause 1 $vp;
        $playblastActive = 0;
		$error = "Playblasting stopped";
        python( "timerTic.stop();timerToc.stop()");
        currentTime -e $originalFrame;
		$launchFcheck = `checkBoxGrp -q -value1 UI_fcheck`;
		if($launchFcheck){
			firePBOpenSequence(1);
		}
firePBrefreshUI;		
    }
}
global proc firePBrefreshUI(){
    global string $error;
    global string $currentFrameFile;
    global int $playblastActive;
	global int $tick;
	
    int $startF = `intFieldGrp -q -value1 UI_startF`;
    int $endF = `intFieldGrp -q -value1 UI_endF`;
    int $incrF = `intFieldGrp -q -value1 UI_incrF`;
	int $timePerF = `intFieldGrp -q -value1 UI_timePerF`;
	
    string $textfieldText ="";
    if($playblastActive){
        $cur = `currentTime -q`;
        $progress =  (($endF-$startF)/$incrF)*$timePerF;
		
		progressBar -edit -step ($tick/$progress*100) UI_progress;
	    $textfieldText = "Playblasting ("+$cur+"/"+$endF+")";
        //textField -e -text ( $text) -en 0 -editable false UI_textfield;
        button -e -label "Stop playblast" -command "firePythonThread(1)"  -h 40 UI_playblast;
    }else{
	    button -e -label "Playblast!" -command "firePythonThread(0)"  -h 40 UI_playblast;
        $incrF = ($incrF < 1)?1:$incrF;
        
		if($timePerF<4){
			$timePerF = 4;
			$error += "WARNING: short wait time = possible crash";
		}
		intFieldGrp -e -value1 $timePerF UI_timePerF;
        optionVar -iv "firePB_secondsperframe" $timePerF;
        $launchFcheck = `checkBoxGrp -q -value1 UI_fcheck`;
        optionVar -sv "firePB_fcheck" (($launchFcheck)?"yes":"no");
        if($endF<$startF){
            intFieldGrp -e -value1 ($startF+1) UI_endF;
        }
        float $tte = (($endF-$startF)*1.0*$timePerF)/$incrF*1.0;
        string $seconds = pad(($tte%60.0));
        $textfieldText = floor($tte/60.0)+"'"+substring($seconds,3,4)+"\" necessary for playblast";

    }
    $textfieldText = ($error!="")?$error+"!":$textfieldText;
    textField -e -text ( $textfieldText) -en 0 -editable false UI_textfield;
    intFieldGrp -e -value1 ($incrF) UI_incrF;
    $error = "";
}
global proc firePBOpenSequence(int $fcheck){
    global string $currentFrameFile;
	global int $frameN;
    if($fcheck){
        int $startF = `intFieldGrp -q -value1 UI_startF`;
        int $endF = `intFieldGrp -q -value1 UI_endF`;
        int $incrF = `intFieldGrp -q -value1 UI_incrF`;
        fcheck  -F -n $startF ($frameN-1) $incrF (`substitute "[.*]([0-9]{4})[\.a-Z]" $currentFrameFile ".#."`);
    }else{
        string $dir = `match "^.*/" $currentFrameFile`;
        if(`about -win`){
            system("start explorer " + toNativePath($dir));
        }
    }
}



http://imgur.com/a/PNd7G#0

var xmlFile = new File("~/Desktop/test.xml");
xmlFile.open("r","TEXT","????");
var content = xmlFile.read();
var xml = new XML(content);
var elements = xml.elements();
alert(elements);
<?xml version="1.0"?>
<collections>
    <expression id="position">ddd</expression>
    <date>2012-10-30</date>
    <icon>thumb2032.png</icon>
</collections>

http://www.programmingforums.org/post168124.html

<html>
<head>
<style type="text/css">
body{ height:100% }
div.fullscreen{
    display:block;
    background-color: #dda;
    /*set the div in the top-left corner of the screen*/
    position:absolute;
    top:0;
    left:0;
float:left;     
    /*set the width and height to 100% of the screen*/
    /*width:100%;*/
    height:100%;
  }
#leftCol {float:left;}

#rightCol {width:200px; float:right}
/*#rightCol div {float:left; clear:left;}*/

/*table, table * {white-space: no-wrap}*/
#nav { white-space:nowrap; padding: 4px 6px; margin: 3px; border: 1px solid #ccc; text-decoration: none; background-color: #add; height: 80%;}
#nav img.a1{height: 100%;}
#nav img.b1{height: 50%;}
#nav img.c1{height: 33%;}
#plop {white-space:nowrap; float:left;height: 33%;background-color: #dad;}
</style>
</head>
<body>
<div class="fullscreen">
<div id="nav">
<div id="leftCol">
<a href='http://etudedeforme.fr/blog/wp-content/uploads/2012/02/fun7_04-120209_1645_0.png'><img class='a1' src='http://etudedeforme.fr/blog/wp-

content/uploads/2012/02/fun7_04-120209_1645_0.png'></a>
<a href='http://etudedeforme.fr/blog/wp-content/uploads/2012/02/fun7_04-120209_1645_0.png'><img class="a1" src='http://etudedeforme.fr/blog/wp-

content/uploads/2012/02/fun7_04-120209_1645_0.png'></a>
<a href='http://etudedeforme.fr/blog/wp-content/uploads/2012/02/fun7_04-120209_1645_0.png'><img class="a1" src='http://etudedeforme.fr/blog/wp-

content/uploads/2012/02/fun7_04-120209_1645_0.png'></a>
</div>
<div id="rightCol">
<a href='http://etudedeforme.fr/blog/wp-content/uploads/2012/02/fun7_04-120209_1645_0.png'><img class='b1' src='http://etudedeforme.fr/blog/wp-

content/uploads/2012/02/fun7_04-120209_1645_0.png'></a>
<a href='http://etudedeforme.fr/blog/wp-content/uploads/2012/02/fun7_04-120209_1645_0.png'><img class="b1" src='http://etudedeforme.fr/blog/wp-

content/uploads/2012/02/fun7_04-120209_1645_0.png'></a>
<a href='http://etudedeforme.fr/blog/wp-content/uploads/2012/02/fun7_04-120209_1645_0.png'><img class="b1" src='http://etudedeforme.fr/blog/wp-

content/uploads/2012/02/fun7_04-120209_1645_0.png'></a>
</div>
</div>
</div>
</body>
</html>