/* op_SmedgeRender.mel * * A script for the openPipeline system to submit jobs to Smedge * Based on a script by Mike Bennett * * Smedge * Copyright (c) 2004 - 2011 Uberware. All Rights Reserved */ /* * To Install: * * You must have openPipeline for this to work properly. Place op_SmedgeRender.mel * in the openPipeline "addons" folder. Obviously, you also need Smedge. * * The first time you run this, it will ask you for the path to the Smedge program folder. * This should be the folder that contains the Submit command line tool. For example: * On Windows: C:\Program Files\Smedge\ * On Mac: /Applications/Smedge.app/Contents/MacOS/ * * To update the list of Pools, press the Refresh Pools button. Note that the Master * must be running when you do this, or it will hang Maya until it connects. * * See the built in Help window for more information and details about operation. */ // opss_GetSmedgeSettingsFile // // Local. Gets the filename for the global Smedge submitter settings file // This file stores the path to the Smedge program folder and the current // list of pools in XML format. // // Inputs: // none // // Returns: // string: the name of the Smedge settings file based on your openPipelin installation proc string opss_GetSmedgeSettingsFile() { // determine the Smedge settings file global string $openPipeline_projectFilePath; if( !`size $openPipeline_projectFilePath` ) error "openPipeline is not set up correctly"; return $openPipeline_projectFilePath + "addons/smedgeSubmitter.xml"; } // opss_GetSmedgePath // // Local. Gets the current value of the Smedge program folder from the // global Smedge submitter settings file. // // Inputs: // none // // Returns: // string: the Smedge submit path that is currently saved in the settings file proc string opss_GetSmedgePath() { string $settings = opss_GetSmedgeSettingsFile(); string $xml[] = openPipelineGetXmlAll( $settings ); string $path[] = openPipelineGetXmlTop( $xml, "SmedgePath" ); return $path[ 0 ]; } // opss_GetLastJobFilename // // Local. Gets the filename for the last used values file for the // submitter control default values. // // Inputs: // none // // Returns: // string: the filename where the last job settings are saved proc string opss_GetLastJobFilename() { int $tab = `optionVar -q "op_currOpenTab"`; string $level1 = `optionVar -q "op_currOpenLevel1"`; string $level2 = `optionVar -q "op_currOpenLevel2"`; string $level3 = `optionVar -q "op_currOpenLevel3"`; string $path = openPipelineGetFileName( $tab, $level1, $level2, $level3, "noteFolder", 0, 0 ); if( `size $path` ) $path += "smedgeSubmitter.xml"; return $path; } // opss_GetLastJobValues // // Local. Gets the last used values for the submitter controls for this // particular scene file. Controls will be initialized to the last used // values, if there are any, to make rendering more consistent. // // Inputs: // none // // Returns: // string: all of the last settings used (or empty if no settings file) proc string opss_GetLastJobValues() { string $all; string $path = opss_GetLastJobFilename(); if( `filetest -r $path` ) { string $xml[] = openPipelineGetXmlAll( $path ); $all = stringArrayToString( openPipelineGetXmlTop( $xml, "LastJob" ), "" ); } return $all; } // opss_GetLastJobValue // // Local. Extracts a specific setting value from the last job values // or returns the given default if no setting was perviously found // // Inputs: // string $all The settings string returnd from opss_GetLastJobValues // string $setting The name of the setting to get the value for // string $default The default value to use if the setting is not found // // Outputs: // string: The value to use for the given setting proc string opss_GetLastJobValue( string $all, string $setting, string $default ) { // look for the given setting string $val = openPipelineGetXmlData( $all, $setting ); if( `size $val` ) return $val; else return $default; } // opss_GetPoolListFromMaster // // Global. Updates the global Smedge submitter settings file with the // current list of pools from the Smedge Master. Note that this will // block the caller until the PoolManager utility connects to and // downloads the list of pools. See comments in the code. // // Inputs: // none // // Outputs: // none global proc opss_GetPoolListFromMaster() { print( "// Getting the list of pools from the Master\n" ); // make sure the user is aware that this can hang Maya string $confirm = `confirmDialog -title "Download Pools" -message "Are you sure you want to download the Pools from the Master?\n\nMaya will be unresponsive until the operation completes. If the Master is not running or the client can't connect, this can hang indefinitely." -button "Yes" -button "No" -defaultButton "Yes" -cancelButton "No" -dismissString "No"`; if( $confirm == "No" ) { print( "// ... Canceled by user\n" ); print "\n"; return; } // turn on the wait cursor waitCursor -state on; // get the settings string $settings = opss_GetSmedgeSettingsFile(); string $smedgePath = opss_GetSmedgePath(); string $cmd = $smedgePath + "PoolManager List Name"; // To keep from blocking Maya if it cannot connect, un-comment this line to add a timeout // $cmd += " -ConnectTimeout 60"; // request pools using PoolManager string $result = `system $cmd`; string $lines[] = stringToStringArray( $result, "\n" ); // generate new file contents string $new[]; $new[ 0 ] = "" + $smedgePath + ""; $new[ 1 ] = ""; int $i = 2; for( $line in $lines ) { $line = strip( $line ); if( $line == "" ) continue; print( "// ... Found Pool: " + $line + "\n" ); $new[ $i ] = " " + $line + ""; $i++; } $new[ $i ] = ""; // turn off the wait cursor now waitCursor -state off; // write out the settings file int $fd = `fopen $settings "w"`; if( !$fd ) error "Could not open Smedge Submitter options file"; for( $each in $new ) fprint $fd ($each + "\n"); fclose $fd; // reopen the window to refresh the pools print( "// Done downloading Pools. Refreshing the Submitter UI\n" ); print "\n"; op_SmedgeRender; } // opss_GetPoolList // // Local. Gets the current list of pools from the global Smedge // submitter settings file. // // Inputs: // none // // Outputs: // An array of strings with the names of all pools (except for "Whole System") proc string[] opss_GetPoolList() { string $settings = opss_GetSmedgeSettingsFile(); string $xml[] = openPipelineGetXmlAll( $settings ); string $all[] = openPipelineGetXmlTop( $xml, "Pools" ); string $pools[] = openPipelineGetXmlSecondary( $all, "Pool" ); return $pools; } // opss_Initialize // // Local. Initialization for the Smedge submitter. If the global Smedge // submitter settings file has not been created yet, it will get the // Smedge program folder from the user, and create the settings file. // // Inputs: // none // // Outputs: // 0 = Failed to initialize (user did not select the Smedge program folder) // 1 = Ready to go. proc int opss_Initialize() { string $settings = opss_GetSmedgeSettingsFile(); string $smedgePath = opss_GetSmedgePath(); string $submit = "Submit"; if( `about -win` ) $submit += ".exe"; // if it's already set up, do nothing if( `filetest -x ($smedgePath + $submit)` ) return 1; // get the path configuration print( "// Initializing Smedge submitter script\n" ); while( !`filetest -d $smedgePath` || !`filetest -x ($smedgePath + $submit)` ) { if( $smedgePath == "" ) print( "// Please set the path to the Smedge program folder\n" ); else warning( "Submit cannot be run from the path: " + $smedgePath ); // create the file string $result[] = `fileDialog2 -fileMode 3 -caption "Select the Smedge program folder" -okCaption "Select"`; // if the user pressed cancel, abort if( !`size $result` ) return 0; $smedgePath = $result[ 0 ]; if( !endsWith( $smedgePath, "/" ) ) $smedgePath += "/"; print( "// Checking folder: " + $smedgePath + "\n" ); } // made it here, then we have a valid path, so save it in the file int $fd = `fopen $settings "w"`; if( !$fd ) error "Could not open Smedge Submitter options file"; fprint $fd ("" + $smedgePath + "\n"); fclose $fd; // successfully initialized return 1; } // opss_GetJobName // // Local. Generates a nice name from the file and version info. // Adds the extra string data from the user in there, too. // // Inputs: // int $ver which version number is being rendered. Set to -1 to get the op_CurrOpenVersion. // string $type which type of scene is being rendered. Leave black to get the op_CurrOpenType. // string $extra the extra text added to the name. // // Outputs: // a string with the generated name proc string opss_GetJobName( int $ver, string $type, string $extra ) { string $jobName; //get information about the currently open file string $currType; if( $type == "" ) $currType = `optionVar -q "op_currOpenType"`; else $currType = $type; string $currCat = `optionVar -q "op_currOpenCategory"`; string $level1 = `optionVar -q "op_currOpenLevel1"`; string $level2 = `optionVar -q "op_currOpenLevel2"`; string $level3 = `optionVar -q "op_currOpenLevel3"`; int $currVersion; if( $ver == -1 ) $currVersion = `optionVar -q "op_currOpenVersion"`; else $currVersion = $ver; int $tab = `optionVar -q "op_currOpenTab"`; $currPath = `openPipelineGetFileName $tab $level1 $level2 $level3 "folder" 0 0`; if( $level1 == "" ) // nothing open in openPipeline? $jobName = "none"; else if( `filetest -d $currPath` ) { string $displayString = ""; string $versionString = ""; // get the workshop and master real names string $wName = `optionVar -q "op_workshopName"`; string $mName = `optionVar -q "op_masterName"`; string $displayType; if ($currType=="workshop") $displayType = $wName; else if ($currType=="master") $displayType = $mName; // workshop or master? if( $currType=="workshop" ) $versionString += $wName + " v." + openPipelinePad( $currVersion, 4 ); else if( $currType=="master" ) $versionString = $mName; // asset or shot? if( $currCat == "asset" || $currCat=="shot" ) { string $assetName = openPipelineGetFolderFromPath( $currPath, 0 ); string $assetType = openPipelineGetFolderFromPath( $currPath, 1 ); $displayString += "(" + interToUI( $currCat ) + ") " + $assetType + "> " + $assetName; } // asset component or shot component? else if( $currCat == "component" || $currCat == "shotComponent" ) { string $assetName = openPipelineGetFolderFromPath($currPath,2); string $assetType = openPipelineGetFolderFromPath($currPath,3); string $compName = openPipelineGetFolderFromPath($currPath,0); $displayString += "(" + interToUI( $currCat ) + ") " + $assetType + "> " + $assetName + "> " + $compName; } // build the name with the project, scene and version $jobName = basename( `workspace -q -sn`, 0 ) + ": " + $displayString + " - " + $versionString; } // add the extra bit if( $extra != "" ) $jobName += " " + $extra; return $jobName; } // opss_GetSubDir // // Local. Generates an appropriate render sub-folder for the // selected scene type and version. // // Inputs: // int $ver The scene version. Set to -1 to get the current version // string $type The type of scene. Leave blank to get the currently open scene type // // Outputs: // string with the generated sub-folder name proc string opss_GetSubDir( int $ver, string $type ) { string $subdir; //get information about the currently open file string $currType; if( $type == "" ) $currType = `optionVar -q "op_currOpenType"`; else $currType = $type; int $tab = `optionVar -q "op_currOpenTab"`; string $currCat = `optionVar -q "op_currOpenCategory"`; string $level1 = `optionVar -q "op_currOpenLevel1"`; string $level2 = `optionVar -q "op_currOpenLevel2"`; string $level3 = `optionVar -q "op_currOpenLevel3"`; int $currVersion; if( $ver == -1 ) { if( $currType == "master" ) $currVersion = openPipelineGetNumVersions( $tab, $level1, $level2, $level3, 0 ) + 1; else $currVersion = `optionVar -q "op_currOpenVersion"`; } else $currVersion = $ver; int $tab = `optionVar -q "op_currOpenTab"`; $currPath = `openPipelineGetFileName $tab $level1 $level2 $level3 "folder" 0 0`; if( $level1 != "" && `filetest -d $currPath` ) { //if the currently open file is an ASSET or SHOT... if( $currCat=="asset" || $currCat=="shot" ) $subdir = openPipelineGetFolderFromPath( $currPath, 1 ) + "/" + openPipelineGetFolderFromPath( $currPath, 0 ); //if the currently open file is a COMPONENT or SHOT COMPONENT... else if ( $currCat=="component" || $currCat=="shotComponent" ) $subdir = openPipelineGetFolderFromPath( $currPath, 3 ) + "/" + openPipelineGetFolderFromPath( $currPath, 2 ) + "/" + openPipelineGetFolderFromPath( $currPath, 0 ); $subdir += "/"; // workshop or master? if ($currType=="workshop") $subdir += interToUI( `optionVar -q "op_workshopName"` ); else if ($currType=="master") $subdir += interToUI( `optionVar -q "op_masterName"` ); // version $subdir += "/" + openPipelinePad( $currVersion, 4 ); } return $subdir; } // opss_GetScene // // Local. Helper function to get the full path to the selected scene file // Also calls the helpers to get the job name and the output sub-folder // at one time. // // Inputs: // none // // Returns: // string array: // element 0: The scene filename // element 1: The Job name // element 2: The output sub-folder proc string[] opss_GetScene() { string $selection = `optionMenu -q -v smedgeVersionSelection`; string $extra = `textField -q -text smedgeNameField`; int $tab = `optionVar -q "op_currOpenTab"`; string $level1 = `optionVar -q "op_currOpenLevel1"`; string $level2 = `optionVar -q "op_currOpenLevel2"`; string $level3 = `optionVar -q "op_currOpenLevel3"`; string $mName = `optionVar -q "op_masterName"`; string $wName = `optionVar -q "op_workshopName"`; string $result[]; if( $selection == "Currently open file" ) { // Currently open scene file $result[ 0 ] = `file -q -exn`; $result[ 1 ] = opss_GetJobName( -1, "", $extra ); $result[ 2 ] = opss_GetSubDir( -1, "" ); } else if( $selection == ("Current "+$mName) ) { // Current Master string $masterFile = openPipelineGetFileName($tab,$level1,$level2,$level3,"master",0,0); $result[ 0 ] = $masterFile; $result[ 1 ] = opss_GetJobName( -1, "master", $extra ); $result[ 2 ] = opss_GetSubDir( -1, "master" ); } else if( startsWith( $selection, $mName ) ) { // An older Master version string $tokenizedList[]; tokenizeList( $selection, $tokenizedList ); int $versionIndex = size( $tokenizedList ) - 1; int $targetVersion = $tokenizedList[ $versionIndex ]; int $latestVersion = openPipelineGetNumVersions( $tab, $level1, $level2, $level3, 0 ); int $versionOffset = $latestVersion - $targetVersion; string $masterFile = openPipelineGetFileName( $tab, $level1, $level2, $level3, "version", $versionOffset, 0 ); $result[ 0 ] = $masterFile; $result[ 1 ] = opss_GetJobName( $targetVersion, "master", $extra ); $result[ 2 ] = opss_GetSubDir( $targetVersion, "master" ); } else if( startsWith( $selection, $wName ) ) { // A specific workshop version string $tokenizedList[]; tokenizeList( $selection, $tokenizedList ); int $versionIndex = size( $tokenizedList )-1; int $targetVersion = $tokenizedList[ $versionIndex ]; int $latestVersion = openPipelineGetNumWorkshops( $tab, $level1, $level2, $level3, 0 ); int $versionOffset = $latestVersion - $targetVersion; string $workshopFile = openPipelineGetFileName( $tab, $level1, $level2, $level3, "workshop", $versionOffset, 0 ); $result[ 0 ] = $workshopFile; $result[ 1 ] = opss_GetJobName( $targetVersion, "workshop", $extra ); $result[ 2 ] = opss_GetSubDir( $targetVersion, "workshop" ); } else { // Hmmm, something is wrong... $result[ 0 ] = "ERROR"; $result[ 1 ] = "ERROR"; $result[ 2 ] = "ERROR"; } return $result; } // opss_SetOutputDir // // Global. Callback for browsing for the output folder // // Inputs: // none // // Returns: // none global proc opss_SetOutputDir() { // ask the user for a folder string $result[] = `fileDialog2 -fileMode 3`; if( `size $result[ 0 ]` ) // set the folder textField -e -tx $result[ 0 ] smedgeOutputFolderField; } // opss_OpenSmedgeGui // // Global. Callback for the button to open the GUI on the UI // // Inputs: // none // // Returns: // none global proc opss_OpenSmedgeGui () { // make sure to start without blocking Maya // On Windows add start to the beginning string $beg = `about -win` ? "start " : ""; // On Unix, direct the output to /dev/null and add & string $end = `about -win` ? "" : " >/dev/null 2>&1 &"; // send the command to start the app string $cmd = $beg + opss_GetSmedgePath() + "SmedgeGui" + $end; print( "// Starting SmedgeGui: " + $cmd + "\n" ); system( $cmd ); } // opss_WriteSmedgeNote // // Local. Creates a new note in the items history detailing the render // // Inputs: // none // // Returns: // 0 Failed to update note // 1 Successfully updated note proc int opss_WriteSmedgeNote () { // Get the openPipeline data needed int $tab = `optionVar -q "op_currOpenTab"`; string $level1 = `optionVar -q "op_currOpenLevel1"`; string $level2 = `optionVar -q "op_currOpenLevel2"`; string $level3 = `optionVar -q "op_currOpenLevel3"`; string $mName = `optionVar -q "op_masterName"`; string $wName = `optionVar -q "op_workshopName"`; // Figure out what we're adding the note to string $whatType = ""; string $versionSelection = `optionMenu -q -v smedgeVersionSelection`; int $version = 0; if( $versionSelection == "Currently open file" ) $version = `optionVar -q "op_currOpenVersion"`; else if( startsWith( $versionSelection, $mName ) || $versionSelection == "Current " + $mName ) $whatType = $mName + " "; else if( startsWith( $versionSelection, $wName ) ) { string $tokenizedList[]; tokenizeList( $versionSelection, $tokenizedList ); int $versionIndex = size( $tokenizedList ) - 1; int $version = $tokenizedList[ $versionIndex ]; $whatType = $wName + " "; } // Generate the note data string $event = "Submitted " + $whatType + "to Smedge"; string $note = `scrollField -q -text smedgeNoteField`; // Add the note int $success = openPipelineAddEventNote( $tab, $level1, $level2, $level3, $event, $version, $note ); // update the openPipeline main window, if needed if( `window -q -ex openPipelineUI` ) openPipelineUpdateCurrentlyOpen; // all done return $success; } // opss_AboutWindow // // Global. Callback to show help window. // // Inputs: // none // // Returns: // none global proc opss_AboutWindow() { // remove the existing help window, if any if (`window -q -exists opss_HelpWindow`) deleteUI opss_HelpWindow; // build the help string string $nl = "\n\n"; string $text="Smedge Submitter is an add-on to openPipeline that simplifies submitting a file to a Smedge render farm."; $text += $nl; $text += "To Install:"; $text += $nl; $text += "You must have openPipeline for this to work properly. Place op_SmedgeRender.mel in the "; $text += "openPipeline \"addons\" folder. Obviously, you also need Smedge."; $text += $nl; $text += "The first time you run this, it will ask you for the path to the Smedge program folder. "; $text += "This should be the folder that contains the Submit command line tool. For example:\n"; $text += "On Windows: C:\\Program Files\\Smedge\\\n"; $text += "On Mac: /Applications/Smedge.app/Contents/MacOS/"; $text += $nl; $text += "To update the list of Pools, press the Refresh Pools button. "; $text += "This uses the PoolManager command line shell, and will block Maya until the "; $text += "operation completes. (It is possible to add a timeout, see the code for the "; $text += "opss_GetPoolsFromMaster() proc). Starting the GUI will not block Maya."; $text += $nl; $text += "Some Notes:"; $text += $nl; $text += "This submitter makes some assumptions and forces some consistent organization."; $text += $nl; $text += "The script assumes you will render the current Master by default."; $text += $nl; $text += "The Range, Packet Size, Priority, Paused, Pool, Output Folder, and Image Format "; $text += "fields will all be initialized to the settings you had last time you submitted "; $text += "the job. To revert these to the default values, use the \"Use Defaults\" button. "; $text += $nl; $text += "There is a field for the Name, but this will not be the job name. The job name "; $text += "is automatically generated based on which file you are rendering. Anything you "; $text += "type in the \"Name\" field will be added to this name, but will not replace the "; $text += "existing naming structure."; $text += $nl; $text += "The script will try to enforce render output and file naming conventions that "; $text += "are consistent. The \"Output Folder\" will be a base folder for an extended "; $text += "folder structure based on which scene and which version you are rendering. "; $text += "The remaining structure is similar to the openPipeline structure in the scenes "; $text += "folder, including the asset type/sequence, asset/shot, master or workshop and "; $text += "version number to match the render with the scene file that created it."; $text += $nl; $text += "The Image Format allows you to render in one of two standard formats that "; $text += "AfterEffects users particularly like based on RenderLayer and RenderPass "; $text += "or just lets you set it up in your render globals. Remember that this is "; $text += "on top of the Output Folder location."; // create the window window -t "About Smedge Submitter" -w 400 -h 250 opss_HelpWindow; formLayout opss_HelpLayout; scrollField -wordWrap true -w 400 -h 200 -text $text -editable false opss_HelpText; button -l "Close" -command "deleteUI -window opss_HelpWindow" opss_HelpClose; // layout the window formLayout -e -attachForm opss_HelpText "top" 5 -attachForm opss_HelpText "left" 5 -attachForm opss_HelpText "right" 5 -attachControl opss_HelpText "bottom" 0 opss_HelpClose -attachForm opss_HelpClose "left" 5 -attachForm opss_HelpClose "right" 5 -attachForm opss_HelpClose "bottom" 5 opss_HelpLayout; // show the window showWindow opss_HelpWindow; } // opss_SaveLastJob // // Local. Helper to save the last submitted job state to a file so that future // submissions of this same job initialize settings the same as the last time // // Inputs: // none // // Returns: // none proc opss_SaveLastJob() { // get the filename string $path = opss_GetLastJobFilename(); // open for writing int $fd = fopen( $path, "w" ); if( !$fd ) error ("Could not open the last job settings file to write: " + $path); // write settings we remember string $val; fprint( $fd, "\n" ); $val = `floatField -q -v "smedgeFromField"`; fprint( $fd, " " + $val + "\n" ); $val = `floatField -q -v "smedgeToField"`; fprint( $fd, " " + $val + "\n" ); $val = `intField -q -v "smedgePacketField"`; fprint( $fd, " " + $val + "\n" ); $val = `intSliderGrp -q -v "smedgePriorityField"`; fprint( $fd, " " + $val + "\n" ); $val = `checkBox -q -v "smedgePaused"` ? 1 : 0; fprint( $fd, " " + $val + "\n" ); $val = `optionMenu -q -sl "smedgePool"`; fprint( $fd, " " + $val + "\n" ); $val = `textField -q -text "smedgeOutputFolderField"`; fprint( $fd, " " + $val + "\n" ); $val = `optionMenu -q -sl "smedgeImageFormatField"`; fprint( $fd, " " + $val + "\n" ); fprint( $fd, "\n" ); // close file fclose $fd; } // opss_UseDefaults // // Global. Callback for the "Use Default" button to reset all submitter // UI fields to the defaults. Works by deleting the last job file and // re-opening the submitter. // // Inputs: // none // // Returns: // none global proc opss_UseDefaults() { // if the last job file exists string $path = opss_GetLastJobFilename(); if( `filetest -r $path` ) // delete it sysFile -delete $path; // update the defaults for the non-scene specific data optionVar -iv "opss_Advanced" 1; // the advanced tab is collapsed optionVar -iv "opss_HistoryNote" 1; // make a note in the OP file history // and re-open the window op_SmedgeRender; } // opss_Submit // // Global. Callback to submit the requested information from the submitter UI. // This must be called from the submitter to work correctly. // // Inputs: // none // // Returns: // none global proc opss_Submit() { int $error = 0; // start building the command string $command = opss_GetSmedgePath() + "Submit Script -type Maya"; // paused? if( `checkBox -q -v smedgePaused` ) $command += " -Paused"; // gets the info about the selected scene file to render string $result[] = opss_GetScene(); if( $result[ 0 ] == "ERROR" ) { print "// ERROR: Couldn't figure out version selection"; $error = 1; } // first element is the scene $command += " -scene " + $result[ 0 ]; // second element is the job name $command += " -name \"" + $result[ 1 ] + "\""; // get the range float $from = `floatField -q -v smedgeFromField`; float $to = `floatField -q -v smedgeToField`; if ($from > $to) { print "// ERROR: First range value must be less then or equal to the second"; $error = 1; } $command += " -range " + $from + "-" + $to; // get the packet size $command += " -packetSize " + `intField -q -v smedgePacketField`; // get the project $command += " -project " + `workspace -q -sn`; // get the priority $command += " -priority " + `intSliderGrp -q -v smedgePriorityField`; // get the output folder string $outputFolder = `textField -q -text smedgeOutputFolderField`; if( $result[ 2 ] != "" ) { // opss_GetScene result also includes custom output folder for this scene if( $outputFolder != "" ) $outputFolder += "/"; $outputFolder += $result[ 2 ]; } if (`size $outputFolder`) $command += " -renderDir " + $outputFolder; // get the pool $command += " -pool " + `optionMenu -q -v smedgePool`; // get the image format int $selectedFormat = `optionMenu -q -sl smedgeImageFormatField`; switch( $selectedFormat ) { case 1: $command += " -extra \"-im _/_\""; break; case 2: $command += " -extra \"-im /\""; break; } // get the note string $note = `scrollField -q -text smedgeNoteField`; if( `size $note` ) $command += " -note " + $note; if( !$error ) { // if no errors, try executing the submit command print( "system (" + $command + ");\n" ); string $result = system( $command ); // process the result string $lines[] = stringToStringArray( $result, "\n" ); int $lastLine = size( $lines ) - 1; if( $lastLine >= 0 && startsWith( $lines[ $lastLine ], "Successfully sent new Job ID: " ) ) { // success! string $id = `substring $lines[ $lastLine ] 31 66`; print( "// Result Job ID: " + $id + "\n" ); // save the note if there is one and we are set to save it if( `size $note` && `checkBox -q -v smedgeHistoryToggle` ) opss_WriteSmedgeNote; // save this as the last submitted job opss_SaveLastJob; // close the submitter window deleteUI wi_op_SmedgeRender; } else print( "// Failed to send job: " + $result + "\n" ); } } // op_SmedgeRender // // Global. Main entry point from openPipeline. Creates UI. // // Inputs: // none // // Returns: // none global proc op_SmedgeRender () { // get our global settings if( !opss_Initialize() ) error( "Could not initialize SmedgeSubmitter" ); // close the old window if it's open if( `window -exists wi_op_SmedgeRender` ) deleteUI wi_op_SmedgeRender; // Initialize openPipeline data int $tab = `optionVar -q "op_currOpenTab"`; string $level1 = `optionVar -q "op_currOpenLevel1"`; string $level2 = `optionVar -q "op_currOpenLevel2"`; string $level3 = `optionVar -q "op_currOpenLevel3"`; string $mName = `optionVar -q "op_masterName"`; string $wName = `optionVar -q "op_workshopName"`; string $settings = opss_GetLastJobValues(); float $initf; int $initi; string $init; // make the window window -t "Smedge Render" wi_op_SmedgeRender; // create the main control layout $form = `formLayout -numberOfDivisions 4`; // Create the controls // Version $r1 = `rowLayout -numberOfColumns 2 -adjustableColumn 2 -columnWidth 1 75 -columnAttach 1 "right" 5 -columnAttach 2 "both" 0`; text -l "Version:"; optionMenu "smedgeVersionSelection"; // Add the version selections menuItem -l "Currently open file"; int $numWorkshops = openPipelineGetNumWorkshops( $tab, $level1, $level2, $level3, 0 ); int $numVersions = openPipelineGetNumVersions( $tab, $level1, $level2, $level3, 0 ); string $masterFile = openPipelineGetFileName( $tab,$level1,$level2,$level3,"master",0,0 ); if( `file -q -ex $masterFile` ) { menuItem -l ("Current " + $mName); // by default, select the current Master if there is one optionMenu -e -sl 2 smedgeVersionSelection; } for( $i = $numVersions; $i > 0; $i-- ) menuItem -l ($mName + " " + $i); for( $i = $numWorkshops; $i > 0; $i-- ) menuItem -l ($wName + " " + $i); setParent ..; // Range $r2 = `rowLayout -numberOfColumns 6 -adjustableColumn 6 -columnWidth 1 75 -columnAttach 1 "right" 5`; text -l "Range:"; $initf = (float) opss_GetLastJobValue( $settings, "RangeStart", `playbackOptions -q -min` ); floatField -precision 0 -v $initf "smedgeFromField"; text -l "-"; $initf = (float) opss_GetLastJobValue( $settings, "RangeEnd", `playbackOptions -q -max` ); floatField -precision 0 -v $initf "smedgeToField"; text -l "Packet Size:"; $initi = (int) opss_GetLastJobValue( $settings, "PacketSize", 1 ); intField -min 1 -v $initi "smedgePacketField"; setParent ..; // Priority $r3 = `rowLayout -numberOfColumns 3 -adjustableColumn 2 -columnWidth 1 75 -columnAttach 1 "right" 5 -columnAttach 2 "both" 0`; text -l "Priority:"; $initi = (int) opss_GetLastJobValue( $settings, "Priority", 50 ); intSliderGrp -field true -minValue 0 -maxValue 100 -v $initi "smedgePriorityField"; $initi = (int) opss_GetLastJobValue( $settings, "Paused", 0 ); checkBox -l "Paused" -v $initi "smedgePaused"; setParent ..; // Pool $r4 = `rowLayout -numberOfColumns 3 -adjustableColumn 2 -columnWidth 1 75 -columnAttach 1 "right" 5 -columnAttach 2 "both" 0`; text -l "Pool:"; optionMenu -w 180 smedgePool; menuItem -l "Whole System"; string $pools[] = opss_GetPoolList(); for( $each in $pools ) menuItem -l $each; $initi = (int) opss_GetLastJobValue( $settings, "Pool", 1 ); optionMenu -e -select $initi smedgePool; button -w 90 -l "Get Pools" -c "opss_GetPoolListFromMaster" -bgc .9 .8 .4; setParent ..; // Advanced $initi = `optionVar -ex "opss_Advanced"` ? `optionVar -q "opss_Advanced"` : 1; $ra = `frameLayout -label "Advanced Overrides" -borderStyle "in" -collapsable true -collapse $initi -collapseCommand "optionVar -iv \"opss_Advanced\" 1" -expandCommand "optionVar -iv \"opss_Advanced\" 0"`; columnLayout -adjustableColumn true -columnAttach "both" 8 -rowSpacing 1; // Name rowLayout -numberOfColumns 2 -adjustableColumn 2 -columnWidth 1 80 -columnAttach 1 "right" 5 -columnAttach 2 "both" 0; text -l "Add to Name:"; textField "smedgeNameField"; setParent ..; // Output Folder rowLayout -numberOfColumns 3 -adjustableColumn 2 -columnWidth 1 80 -columnAttach 1 "right" 5 -columnAttach 2 "both" 0; text -l "Output Folder:"; // default base Output Folder is the images folder of your project string $defaultDirPath = `workspace -q -sn` + "/" + `workspace -rte images`; $init = opss_GetLastJobValue( $settings, "OutputFolder", $defaultDirPath ); textField -text $init "smedgeOutputFolderField"; button -label "..." -c "opss_SetOutputDir"; setParent ..; // Image Format rowLayout -numberOfColumns 2 -adjustableColumn 2 -columnWidth 1 80 -columnAttach 1 "right" 5 -columnAttach 2 "both" 0; text -l "Image Format:"; optionMenu -w 180 smedgeImageFormatField; // Hard coded choice of naming conventions menuItem -l "_/_"; menuItem -l "/"; menuItem -itl on -l "Use the scene settings"; $initi = (int) opss_GetLastJobValue( $settings, "ImageNameFormat", 1 ); optionMenu -e -select $initi smedgeImageFormatField; setParent ..; setParent ..; setParent ..; // Notes $l1 = `text -align "right" -l "Notes:"`; $n1 = `scrollField -height 80 -wordWrap 1 smedgeNoteField`; $initi = `optionVar -ex "opss_HistoryNote"` ? `optionVar -q "opss_HistoryNote"` : 1; $n2 = `checkBox -l "Make a note in file history" -v $initi -onCommand "optionVar -iv \"opss_HistoryNote\" 1" -offCommand "optionVar -iv \"opss_HistoryNote\" 0" "smedgeHistoryToggle"`; // Buttons $b1 = `button -l "Submit" -c "opss_Submit" -bgc .4 .9 .4`; $b2 = `button -l "Cancel" -c "deleteUI wi_op_SmedgeRender;" -bgc .8 .4 .4`; $b3 = `button -l "Help" -c "opss_AboutWindow"`; $b4 = `button -l "Smedge GUI" -c "opss_OpenSmedgeGui"`; $b5 = `button -l "Refresh UI" -c "op_SmedgeRender"`; $b6 = `button -l "Use Defaults" -c "opss_UseDefaults"`; setParent ..; // layout the controls int $marginSmall = 2; int $marginLarge = 5; int $labelOffset = 75; formLayout -edit -attachForm $r1 "top" $marginLarge -attachForm $r1 "left" $marginLarge -attachForm $r1 "right" $marginLarge -attachControl $r2 "top" $marginSmall $r1 -attachForm $r2 "left" $marginLarge -attachForm $r2 "right" $marginLarge -attachControl $r3 "top" $marginSmall $r2 -attachForm $r3 "left" $marginLarge -attachForm $r3 "right" $marginLarge -attachControl $r4 "top" $marginSmall $r3 -attachForm $r4 "left" $marginLarge -attachForm $r4 "right" $marginLarge -attachControl $ra "top" $marginSmall $r4 -attachForm $ra "left" $marginLarge -attachForm $ra "right" $marginLarge -attachControl $l1 "top" $marginSmall $ra -attachForm $l1 "left" $marginLarge -attachControl $l1 "right" $marginLarge $n1 -attachControl $n1 "top" $marginSmall $ra -attachForm $n1 "left" $labelOffset -attachForm $n1 "right" $marginLarge -attachControl $n1 "bottom" $marginSmall $n2 -attachForm $n2 "left" $labelOffset -attachForm $n2 "right" $marginLarge -attachControl $n2 "bottom" $marginLarge $b1 -attachForm $b1 "left" $marginLarge -attachPosition $b1 "right" $marginSmall 2 -attachControl $b1 "bottom" $marginLarge $b3 -attachPosition $b2 "left" $marginSmall 2 -attachForm $b2 "right" $marginLarge -attachControl $b2 "bottom" $marginLarge $b3 -attachForm $b3 "left" $marginLarge -attachPosition $b3 "right" $marginSmall 1 -attachForm $b3 "bottom" $marginLarge -attachPosition $b4 "left" $marginSmall 1 -attachPosition $b4 "right" $marginSmall 2 -attachForm $b4 "bottom" $marginLarge -attachPosition $b5 "left" $marginSmall 2 -attachPosition $b5 "right" $marginSmall 3 -attachForm $b5 "bottom" $marginLarge -attachPosition $b6 "left" $marginSmall 3 -attachForm $b6 "right" $marginLarge -attachForm $b6 "bottom" $marginLarge $form; showWindow wi_op_SmedgeRender; }