// =========================================================================== // 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. // =========================================================================== // // Procedure Name: // AEAlembicNodeTemplate // // Description Name; // Creates the attribute editor controls for the AlembicNode node // // Input Value: // nodeName // // Output Value: // None // // This is the procedure to open a file browser to choose a cache file // global proc AEAlembicFileBrowser( string $fileNameAttr ) { // prepare filter and starting dir for file dialog string $filter = (uiRes("m_AEalembicNodeTemplate.kAlembic")) + " (*.abc);;" + (uiRes("m_AEalembicNodeTemplate.kAllFiles")) + " (*.*)"; if (size(`workspace -fileRuleEntry alembicCache`) == 0) { workspace -fileRule "alembicCache" "cache/alembic"; workspace -saveWorkspace; } string $workspace = `workspace -fileRuleEntry alembicCache`; $workspace = `workspace -expandName $workspace`; // choose a file to import string $result[] = `fileDialog2 -returnFilter 1 -fileFilter $filter -dialogStyle 2 -caption (uiRes("m_AEalembicNodeTemplate.kAssignCacheFile")) -startingDirectory $workspace -fileMode 1 `; if (size($result) == 0 || size($result[0]) == 0) { // cancelled return; } // set the file name attribute of the cache node setAttr $fileNameAttr -type "string" $result[0]; // This will force an update to display the effects // of the new cachefile. // currentTime `currentTime -q`; } // The following two procedures generate the UI for file name field // global proc AEAlembicNodeFileNameNew ( string $fileNameAttr ) { setUITemplate -pushTemplate attributeEditorTemplate; columnLayout -adjustableColumn true; rowLayout -numberOfColumns 3; text -label (uiRes("m_AEalembicNodeTemplate.kAbcFile")) fileNameText; textField fileNameField; symbolButton -image "navButtonBrowse.png" browser; setParent ..; // rowLayout -numberOfColumns 3 -columnAttach3 both left both; // separator -style none; // push the symbol button to the 2nd column // symbolButton -image "refresh.png" -annotation _L10N(kReload,"Reload the cache file") reloadButton; // setParent ..; setParent ..; setUITemplate -popTemplate; AEAlembicNodeFileNameReplace( $fileNameAttr ); } global proc AEAlembicNodeFileNameReplace ( string $fileNameAttr ) { string $fileName = `getAttr $fileNameAttr`; string $nodeName = `plugNode $fileNameAttr`; // file name attribute // connectControl -fileName fileNameField $fileNameAttr; button -e -c ("AEAlembicFileBrowser " + $fileNameAttr) browser; // symbolButton -e -command ("gpuCache -e -refresh " + $nodeName) reloadButton; } global proc AEAlembicNodeTemplate( string $nodeName ) { editorTemplate -beginScrollLayout; editorTemplate -beginLayout (uiRes("m_AEalembicNodeTemplate.kAEAlembicAttributes")) -collapse 0; editorTemplate -callCustom AEAlembicNodeFileNameNew AEAlembicNodeFileNameReplace "abc_File"; editorTemplate -addControl "startFrame"; editorTemplate -addControl "endFrame"; editorTemplate -addControl "time"; editorTemplate -addControl "speed"; editorTemplate -addControl "offset"; editorTemplate -addControl "cycleType"; editorTemplate -endLayout; AEdependNodeTemplate $nodeName; editorTemplate -addExtraControls; editorTemplate -endScrollLayout; }