// =========================================================================== // Copyright 2018 Autodesk, Inc. All rights reserved. // // Use of this software is subject to the terms of the Autodesk license // agreement provided at the time of installation or download, or which // otherwise accompanies this software in either electronic or hard copy form. // =========================================================================== // // Description: // This script contains the import EDL option box dialog // global proc int doImportEDL( int $useStartFrameOverride, float $startFrame, string $fileName, string $fileType) { if( $fileType != "edl" ) return 0; python("import maya.app.edl.importExport as EDL"); python("EDL.doImport(\"" + $fileName + "\", " + $useStartFrameOverride + ", " + $startFrame + ")"); return 1; } proc setOptionVars (int $forceFactorySettings) { if( $forceFactorySettings || !`optionVar -exists importEDLStartFrameOverrideEnabled` ) { optionVar -intValue importEDLStartFrameOverride 0; } if ( $forceFactorySettings || !`optionVar -exists importEDLStartFrameOverride`) { optionVar -floatValue importEDLStartFrameOverride 1.0; } } // // Procedure Name: // importEDLSetup // // Description: // Update the state of the option box UI to reflect the option values. // // Input Arguments: // parent - Top level parent layout of the option box UI. // Required so that UI object names can be // successfully resolved. // // forceFactorySettings - Whether the option values should be set to // default values. // // Return Value: // None. // global proc importEDLSetup (string $parent, int $forceFactorySettings) { // Retrieve the option settings. setOptionVars( $forceFactorySettings ); setParent $parent; // Set the start and end times. int $override = `optionVar -query importEDLStartFrameOverrideEnabled`; checkBoxGrp -e -v1 $override startFrameEnabled; floatFieldGrp -e -v1 `optionVar -q importEDLStartFrameOverride` -enable $override startFrameValue; } // // Procedure Name: // importEDLCallback // // Description: // Update the option values with the current state of the option box UI. // // Input Arguments: // parent - Top level parent layout of the option box UI. Required so // that UI object names can be successfully resolved. // // doIt - Whether the command should execute. // // Return Value: // None. // global proc importEDLCallback (string $parent, int $doIt) { setParent $parent; optionVar -intValue importEDLStartFrameOverrideEnabled `checkBoxGrp -q -v1 startFrameEnabled`; optionVar -floatValue importEDLStartFrameOverride `floatFieldGrp -q -value1 startFrameValue`; if ($doIt) { performImportEDL 0; } } global proc importEDLUpdateEnableState( ) { floatFieldGrp -e -enable `checkBoxGrp -q -v1 startFrameEnabled` startFrameValue; } proc string importEDLWidgets( string $parent ) { setParent $parent; string $tabForm = `columnLayout -adj true`; checkBoxGrp -ncb 1 -label (uiRes("m_performImportEDL.kStartFrameOverride")) -cc importEDLUpdateEnableState startFrameEnabled; floatFieldGrp -numberOfFields 1 -label (uiRes("m_performImportEDL.kFrame")) startFrameValue; setParent ..; return $tabForm; } global proc importEDLOptions ( ) { string $commandName = "importEDL"; // Build the option box "methods" // string $callback = ($commandName + "Callback"); string $setup = ($commandName + "Setup"); // Get the option box. // // The value returned is the name of the layout to be used as // the parent for the option box UI. // string $layout = getOptionBox(); setParent $layout; setOptionBoxCommandName("importEDL"); setUITemplate -pushTemplate DefaultTemplate; waitCursor -state 1; tabLayout -scr true -tv false; // To get the scroll bars string $parent = `columnLayout -adjustableColumn 1`; importEDLWidgets $parent; waitCursor -state 0; setUITemplate -popTemplate; // 'Apply' button. // string $applyBtn = getOptionBoxApplyBtn(); button -edit -label (uiRes("m_performImportEDL.kImportEDL")) -command ($callback + " " + $parent + " " + 1 ) $applyBtn; // 'Save' button. // string $saveBtn = getOptionBoxSaveBtn(); button -edit -command ($callback + " " + $parent + " " + 0 + "; hideOptionBox") $saveBtn; // 'Reset' button. // string $resetBtn = getOptionBoxResetBtn(); button -edit -command ($setup + " " + $parent + " " + 1) $resetBtn; // Set the option box title. // setOptionBoxTitle (uiRes("m_performImportEDL.kImportEDLOptions")); setOptionBoxHelpTag( "ImportEDL" ); // Set the current values of the option box. // eval (($setup + " " + $parent + " " + 0)); // Show the option box. // showOptionBox(); } // // Procedure Name: // assembleCmd // // Description: // Construct the command that will apply the option box values. // // Input Arguments: // None. // // Return Value: // None. // proc string assembleCmd( ) { string $cmd; setOptionVars(false); $cmd = "doImportEDL " + `optionVar -q importEDLStartFrameOverrideEnabled` + " " + `optionVar -q importEDLStartFrameOverride`; string $fileLabel = (uiRes("m_performImportEDL.kFileBroswerImport")); $cmd = "fileBrowser(\"" + $cmd + "\", \""+ $fileLabel+ "\", \"edl\", 0)"; return $cmd; } // // Procedure Name: // performImportEDL // // Description: // Import a Final Cut Pro XML or AAF file. // This procedure will also show the option box // window if necessary as well as construct the command string // that will split a shot with the current option box values. // // Input Arguments: // $action: 0 - Execute the command. // 1 - Show the option box dialog. // 2 - Return the command. // // Return Value: // None. // global proc string performImportEDL (int $action) { string $cmd = ""; switch ($action) { // Execute the command. // case 0: // Retrieve the option settings // setOptionVars(false); // Get the command. // $cmd = assembleCmd(); // Execute the command with the option settings. // if ($cmd != "") evalEcho($cmd); break; // Show the option box. // case 1: importEDLOptions(); break; case 2: // Get the command. // $cmd = assembleCmd(); } return $cmd; }