// =========================================================================== // 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 is executed when a new scene file is created. It will create // panels if required or use existing panels. // // Creation Date: // global proc buildNewSceneUI() { global string $gMainPane; global string $gNewScenePanelConfig; global int $gUseNewScenePanelConfig; int $menusOkayInPanels = `optionVar -q allowMenusInPanels`; int $useNewSceneConfig = $gUseNewScenePanelConfig; string $panels[] = `getPanel -all`; if( size($panels) == 1 ){ if( $panels[0] == "renderWindowPanel1" ){ // We've run into bug #349231, and bug #349651 hasn't been fixed // yet; clear $panels so we can build the rest of the panels. // clear $panels; } } if (!$useNewSceneConfig && (size($panels) == 0)) { // // Currently no panels so use the new scene panels anyway. // $useNewSceneConfig = true; } if (`paneLayout -exists $gMainPane`) { // // get current state of the UI // sceneUIReplacement -update $gMainPane; // Model Views // if (`exists modelPanel`) { rememberViewportSettings("Top View", "top"); rememberViewportSettings("Side View", "side"); rememberViewportSettings("Front View", "front"); rememberViewportSettings("Persp View", "persp"); } if ($useNewSceneConfig) { // // Start building panels for the new scene. // int $i; int $count = 0; int $nVis = `paneLayout -q -nvp $gMainPane`; string $type; string $types[4]; string $panelName; string $editorName; string $itemFilterName; string $subFilter1, $subFilter2; if ( `exists stereoCameraView` ) { $panelLabel = localizedPanelLabel("Stereo"); $panelName = `sceneUIReplacement -getNextPanel "scriptedPanel" $panelLabel`; if ("" == $panelName) { $panelName = `scriptedPanel -mbv $menusOkayInPanels -parent $gMainPane -label $panelLabel`; } else { scriptedPanel -edit -label $panelLabel $panelName; } $editorName = ($panelName + "Editor"); resetModelEditor( `findStartUpCamera persp`, $editorName ); } if (`exists outlinerPanel`) { // Redraw the toggled outliner // global string $gToggledOutlinerLabel; $panelName = `sceneUIReplacement -getNextPanel "outlinerPanel" $gToggledOutlinerLabel`; if ("" == $panelName){ global int $gOutlinerPanelNeedsInit; $gOutlinerPanelNeedsInit = true; initOutlinerPanel(); } else { attachOutlinerToForm(); } $panelLabel = localizedPanelLabel("Outliner" ); $panelName = `sceneUIReplacement -getNextPanel "outlinerPanel" $panelLabel`; if ("" == $panelName) { $panelName = `outlinerPanel -mbv $menusOkayInPanels -unParent -label $panelLabel`; } else { outlinerPanel -edit -label $panelLabel $panelName; } } if (`isTrue AnimationExists`) { $panelLabel = localizedPanelLabel("Graph Editor" ); $panelName = `sceneUIReplacement -getNextScriptedPanel "graphEditor" $panelLabel`; if ("" == $panelName) { $panelName = `scriptedPanel -mbv $menusOkayInPanels -unParent -type "graphEditor" -label $panelLabel`; } else { scriptedPanel -edit -label $panelLabel $panelName; } $editorName = ($panelName+"OutlineEd"); outlinerEditor -e -mainListConnection "graphEditorList" -selectionConnection ($panelName + "FromOutliner") -highlightConnection "keyframeList" -showShapes 1 -showAttributes 1 -showConnected 1 -showAnimCurvesOnly 1 -autoExpand 1 -showDagOnly 0 -ignoreDagHierarchy 0 -expandConnections 1 -showCompounds 0 -showNumericAttrsOnly 1 -highlightActive 0 -autoSelectNewObjects 1 -doNotSelectNewObjects 0 -transmitFilters 1 -showSetMembers 0 -showTimeEditor 1 $editorName; $editorName = ($panelName+"GraphEd"); animCurveEditor -e -mainListConnection ($panelName + "FromOutliner") -displayKeys 1 -displayTangents 0 -displayActiveKeys 0 -displayActiveKeyTangents 1 -displayInfinities 0 -autoFit 0 -snapTime "integer" -snapValue "none" -smoothness "fine" -resultSamples 1 $editorName; $panelLabel = localizedPanelLabel("Dope Sheet" ); $panelName = `sceneUIReplacement -getNextScriptedPanel "dopeSheetPanel" $panelLabel`; if ("" == $panelName) { $panelName = `scriptedPanel -mbv $menusOkayInPanels -unParent -type "dopeSheetPanel" -label $panelLabel`; } else { scriptedPanel -edit -label $panelLabel $panelName; } $editorName = ($panelName+"OutlineEd"); outlinerEditor -e -mainListConnection "animationList" -selectionConnection ($panelName + "OutlinerSelection") -highlightConnection keyframeList -showShapes 1 -showAttributes 1 -showConnected 1 -showAnimCurvesOnly 1 -autoExpand 0 -showDagOnly 0 -ignoreDagHierarchy 0 -expandConnections 1 -showCompounds 1 -showNumericAttrsOnly 1 -highlightActive 0 -autoSelectNewObjects 0 -doNotSelectNewObjects 1 -transmitFilters 0 -showSetMembers 0 -showTimeEditor 1 $editorName; $editorName = ($panelName+"DopeSheetEd"); dopeSheetEditor -e -mainListConnection ($panelName + "FromOutliner") -highlightConnection ($panelName + "OutlinerSelection") -displayKeys 1 -displayTangents 0 -displayActiveKeys 0 -displayActiveKeyTangents 0 -displayInfinities 0 -autoFit 0 -snapTime "integer" -snapValue "none" -outliner ($panelName + "OutlineEd") $editorName; { $panelLabel = localizedPanelLabel("Time Editor" ); $panelName = `sceneUIReplacement -getNextScriptedPanel "timeEditorPanel" $panelLabel`; if ("" == $panelName) { $panelName = `scriptedPanel -mbv $menusOkayInPanels -unParent -type "timeEditorPanel" -label $panelLabel`; } else { scriptedPanel -edit -label $panelLabel $panelName; } } $panelLabel = localizedPanelLabel("Trax Editor" ); $panelName = `sceneUIReplacement -getNextScriptedPanel "clipEditorPanel" $panelLabel`; if ("" == $panelName) { $panelName = `scriptedPanel -mbv $menusOkayInPanels -unParent -type "clipEditorPanel" -label $panelLabel`; } else { scriptedPanel -edit -label $panelLabel $panelName; } $editorName = clipEditorNameFromPanel($panelName); clipEditor -edit -mainListConnection clipEditorList $editorName; clipEditor -edit -lockMainConnection $editorName; $panelLabel = localizedPanelLabel("Camera Sequencer" ); $panelName = `sceneUIReplacement -getNextScriptedPanel "sequenceEditorPanel" $panelLabel`; if ("" == $panelName) { $panelName = `scriptedPanel -mbv $menusOkayInPanels -unParent -type "sequenceEditorPanel" -label $panelLabel`; } else { scriptedPanel -edit -label $panelLabel $panelName; } $editorName = sequenceEditorNameFromPanel($panelName); clipEditor -edit -lockMainConnection $editorName; } if (`exists hyperGraph`) { // Save the current state of hypergraph panels saveHypergraphSettings; $panelLabel = localizedPanelLabel( "Hypergraph Hierarchy" ); $panelName = `sceneUIReplacement -getNextScriptedPanel "hyperGraphPanel" $panelLabel`; if ("" == $panelName) { $panelName = `scriptedPanel -mbv $menusOkayInPanels -unParent -type "hyperGraphPanel" -label $panelLabel`; } else { scriptedPanel -edit -label $panelLabel $panelName; } $editorName = ($panelName+"HyperGraphEd"); hyperGraph -e -image "" -graphType "DAG" $editorName; $panelLabel = localizedPanelLabel("Hypershade"); $panelName = `sceneUIReplacement -getNextScriptedPanel "hyperShadePanel" $panelLabel`; if ("" == $panelName) { $panelName = `scriptedPanel -mbv $menusOkayInPanels -unParent -type "hyperShadePanel" -label $panelLabel`; } else { scriptedPanel -edit -label $panelLabel $panelName; } $panelLabel = localizedPanelLabel("Visor"); $panelName = `sceneUIReplacement -getNextScriptedPanel "visorPanel" $panelLabel`; if ("" == $panelName) { $panelName = `scriptedPanel -mbv $menusOkayInPanels -unParent -type "visorPanel" -label $panelLabel`; } else { scriptedPanel -edit -label $panelLabel $panelName; } } $panelLabel = localizedPanelLabel( "Node Editor" ); $panelName = `sceneUIReplacement -getNextScriptedPanel "nodeEditorPanel" $panelLabel`; if ("" == $panelName) { $panelName = `scriptedPanel -mbv $menusOkayInPanels -unParent -type "nodeEditorPanel" -label $panelLabel`; } else { // Keep all currently open Node Editor panels while("" != $panelName) { scriptedPanel -edit -label $panelLabel $panelName; $panelName = `sceneUIReplacement -getNextScriptedPanel "nodeEditorPanel" $panelLabel`; } } if (`exists nodeTreeLister`) { $panelLabel = localizedPanelLabel( "Create Node" ); $panelName = `sceneUIReplacement -getNextScriptedPanel "createNodePanel" $panelLabel`; if ("" == $panelName) { $panelName = `scriptedPanel -mbv $menusOkayInPanels -unParent -type "createNodePanel" -label $panelLabel`; } else { scriptedPanel -edit -label $panelLabel $panelName; } $editorName = ($panelName+"NodeEditorEd"); } if (`isTrue "PolyTextureExists"`) { $panelLabel = localizedPanelLabel("UV Editor" ); $panelName = `sceneUIReplacement -getNextScriptedPanel "polyTexturePlacementPanel" $panelLabel`; if ("" == $panelName) { $panelName = `scriptedPanel -mbv $menusOkayInPanels -unParent -type "polyTexturePlacementPanel" -label $panelLabel`; } else { $label = `panel -q -label $panelName`; scriptedPanel -edit -label $panelLabel $panelName; } } if (`isTrue "RenderingExists"`) { if (true) { $panelLabel = localizedPanelLabel("Render View"); $panelName = `sceneUIReplacement -getNextScriptedPanel "renderWindowPanel" $panelLabel`; if ("" == $panelName) { $panelName = `scriptedPanel -mbv $menusOkayInPanels -unParent -type "renderWindowPanel" -label $panelLabel renderView`; } else { $label = `panel -q -label $panelName`; scriptedPanel -edit -label $panelLabel $panelName; } } } if (`exists shapePanel`) { $shapePanelLabel = localizedPanelLabel("Shape Editor" ); $shapePanelName = `sceneUIReplacement -getNextPanel "shapePanel" $shapePanelLabel`; if ("" == $shapePanelName) { $shapePanelName = `shapePanel -mbv $menusOkayInPanels -unParent -label $shapePanelLabel`; } else { $label = `panel -q -label $shapePanelName`; shapePanel -edit -label $shapePanelLabel $shapePanelName; } } if (`exists posePanel`) { $posePanelLabel = localizedPanelLabel("Pose Editor" ); $posePanelName = `sceneUIReplacement -getNextPanel "posePanel" $posePanelLabel`; if ("" == $posePanelName) { $posePanelName = `posePanel -mbv $menusOkayInPanels -unParent -label $posePanelLabel`; } else { $label = `panel -q -label $posePanelName`; posePanel -edit -label $posePanelLabel $posePanelName; } } if (`isTrue "DynamicsExists"`) { $panelLabel = localizedPanelLabel("Dynamic Relationships" ); $panelName = `sceneUIReplacement -getNextScriptedPanel "dynRelEdPanel" $panelLabel`; if ("" == $panelName) { $panelName = `scriptedPanel -mbv $menusOkayInPanels -unParent -type "dynRelEdPanel" -label $panelLabel`; } else { $label = `panel -q -label $panelName`; scriptedPanel -edit -label $panelLabel $panelName; } } if (`exists relationshipEditor`) { $panelLabel = localizedPanelLabel("Relationship Editor"); $panelName = `sceneUIReplacement -getNextScriptedPanel"relationshipPanel" $panelLabel`; if ("" == $panelName) { $panelName = `scriptedPanel -mbv $menusOkayInPanels -unParent -type "relationshipPanel" -label $panelLabel`; } else { scriptedPanel -edit -label $panelLabel $panelName; } } if (`exists referenceEditorPanel`) { $panelLabel = localizedPanelLabel("Reference Editor" ); $panelName = `sceneUIReplacement -getNextScriptedPanel"referenceEditorPanel" $panelLabel`; if ("" == $panelName) { $panelName = `scriptedPanel -mbv $menusOkayInPanels -unParent -type "referenceEditorPanel" -label $panelLabel`; } else { $label = `panel -q -label $panelName`; scriptedPanel -edit -label $panelLabel $panelName; } } if (`exists componentEditorPanel`) { $panelLabel = localizedPanelLabel("Component Editor" ); $panelName = `sceneUIReplacement -getNextScriptedPanel"componentEditorPanel" $panelLabel`; if ("" == $panelName) { $panelName = `scriptedPanel -mbv $menusOkayInPanels -unParent -type "componentEditorPanel" -label $panelLabel`; } else { $label = `panel -q -label $panelName`; scriptedPanel -edit -label $panelLabel $panelName; } } if (`isTrue MayaCreatorExists` && `scriptedPanelType -exists dynPaintScriptedPanelType`) { $panelLabel = localizedPanelLabel("Paint Effects" ); $panelName = `sceneUIReplacement -getNextScriptedPanel "dynPaintScriptedPanelType" $panelLabel`; if ("" == $panelName) { $panelName = `scriptedPanel -unParent -type "dynPaintScriptedPanelType" -label $panelLabel dynPaintScriptedPanel`; } else { scriptedPanel -edit -label $panelLabel $panelName; } dynPaintPanel $panelName; } if (`exists scriptEditorPanel`) { $panelLabel = localizedPanelLabel("Script Editor" ); $panelName = `sceneUIReplacement -getNextScriptedPanel "scriptEditorPanel" $panelLabel`; if ("" == $panelName) { $panelName = `scriptedPanel -mbv $menusOkayInPanels -unParent -type "scriptEditorPanel" -label $panelLabel`; } else { $label = `panel -q -label $panelName`; scriptedPanel -edit -label $panelLabel $panelName; } } if (`exists profilerPanel`) { $panelLabel = localizedPanelLabel( "Profiler Tool" ); $panelName = `sceneUIReplacement -getNextScriptedPanel "profilerPanel" $panelLabel`; if ("" == $panelName) { $panelName = `scriptedPanel -mbv $menusOkayInPanels -unParent -type "profilerPanel" -label $panelLabel`; } else { $label = `panel -q -label $panelName`; scriptedPanel -edit -label $panelLabel $panelName; } } if (`exists contentBrowserPanel`){ $panelLabel = localizedPanelLabel("Content Browser"); $panelName = `sceneUIReplacement -getNextScriptedPanel "contentBrowserPanel" $panelLabel`; if ("" == $panelName) { $panelName = `scriptedPanel -unParent -type "contentBrowserPanel" -label $panelLabel`; } else { $label = `panel -q -label $panelName`; scriptedPanel -edit -label $panelLabel $panelName; } } sceneUIReplacement -clear; setNamedPanelLayout $gNewScenePanelConfig; panelHistory -e -clear mainPanelHistory; setFocus `paneLayout -q -p1 $gMainPane`; } } // View Cube - create and set options according to saved prefs // viewManip -visible `optionVar -q viewCubeShowCube` -size `optionVar -q viewCubeSize` -minOpacity `optionVar -q viewCubeInactiveOpacity` -dragSnap `optionVar -q viewCubeSnapToClosest` -preserveSceneUp `optionVar -q viewCubePreserveSceneUp` -zoomToFitScene `optionVar -q viewCubeFitToView` -drawCompass `optionVar -q viewCubeShowCompass` -compassAngle `optionVar -q viewCubeCompassAngle`; string $viewCubePos = `optionVar -q viewCubeScreenPosition`; // Note: $viewCubePos is in form "topRight", "topLeft" etc. // so this will do "viewManip -topRight" for example string $viewCubeAdjustPositionCmd = "viewManip -" + $viewCubePos; eval( $viewCubeAdjustPositionCmd ); // allow textManip, used by the headsUpMessage command // textManip -visible true; // Create an instance of universal manipulator // (Use shared flag to make sure we don't get more than one). createNode xformManip -shared -name "UniversalManip"; select -clear; // Set local or world space int $space = `optionVar -q xformManipWorldSpace`; setXformManip -ws $space; // Set rotate option int $usePivot = `optionVar -q xformManipUseRotatePivot`; setXformManip -urp $usePivot; // Hide units display on universal manipulator setXformManip -showUnits off; // Hide universal manipulator initially setXformManip -suppress on; // Invoke any user supplied code. This callback is published and // needs to remain consistent in future versions of Maya. // if (exists ("buildNewSceneUserCallback") ) { // Use catchQuiet in case no callback is supplied, we don't want that to // show an error catchQuiet( eval("source \"buildNewSceneUserCallback\"") ); } if (!exists("filterUIRestoreAllSavedSettings")) { eval("source \"filterUI.mel\""); } filterUIRestoreAllSavedSettings(); }