一半君的总结纸

听话只听一半君

#110 如何添加或修改Maya默认菜单?

精神病院里某人问道,2014里的blind data editor哪里去了?

以前是在Window->General Editors里,好吧也许是自动桌觉得这种东西没必要单独占一个菜单,所以把他拿掉了,如果你有强迫症的话,你可以把他再加回去

如何加到”主”菜单

{
    global string $gMainWindowMenu;

    // 如果你之前没有显示过菜单,那么他们还不存在
    if (size(`menu -q -ia $gMainWindowMenu`)==0)
        eval(`menu -q -pmc $gMainWindowMenu`);
    string $menus[]=`menu -q -ia $gMainWindowMenu`;

    // 同理
    if (size(`menu -q -ia $menus[0]`)==0)
        eval(`menu -q -pmc $menus[0]`);

    // 自己加一个
    menuItem -d true -p $menus[0];
    menuItem -l "Holycrab Editor !!!" -c "blindDataEditor" -p $menus[0];
}

上面是把他加到了最后一个菜单的后面,如果你想进去,加到Channel Control的上面要怎么做到?

有两种办法:

  • 找到这个菜单对应的mel文件,把他拷到另一个在MAYA_SCRIPTS_PATH里排在前面的路径里,在里面把你想加的菜单加上,这样做的缺陷是这个文件只适合你拷出文件的Maya版本,因为很难说不同版本的Maya这个文件是不是完全一样的
  • 把上面的菜单先存好,然后把他们删掉,加我想加的菜单,再把刚才删掉的菜单加回去,虽然很脑残,不过直接法也只能这样了

找到对应mel文件的方法是,打开Echo All Commands, 然后会看到当鼠标指向General Editors菜单的时候,执行的是

buildObjectEdMenu MayaWindow|mainWindowMenu|menuItem76;

用whatIs 命令可以知道他在哪里

whatIs buildObjectEdMenu;
// Result: Mel procedure found in: /home/oglop/maya/2015-x64/scripts/WindowMenu.mel // 

此外,主菜单ui的名字都是$gXXXX开头的全局变量,可以用env命令显示,顾名思义也能知道哪个对应哪个了

env;
// Result: $gScriptedModelEditorTypes $gScriptedModelEditorList $gPanelLabels $gResourceFileList $gPrefsCustomTabSetOptVarToDefault $gMayaVersionYear $gColorMgtColorManagedNodes $gColorMgtNodesMissingColorSpaces $gAvailableLanguages $gHelpLanguage $gPreviousWorkingUnitLinear $AttrPaintPolyShapes $AttrPaintPolyClr $AttrPaintInstOn $updateUIProcs $hardwareRenderSelectedFlag $gPreferenceWindow $gModeOptionsMenu $gUseMenusInPanels $gSelItems $gCustomSelPriority $gSuitesInteractionMode $gSuitesInteractionModeChange $gMainWindow $gCommandWindow $gNewScenePanelConfig $gUseNewScenePanelConfig $gUseScenePanelConfig $gUseSaveScenePanelConfig $gMaxTexResSliderStr $gLineWidthSliderStr $gPlayBackSlider $gSelectPriorityMode $gDefaultFileBrowserDir $gOldCurrentDirectory $gv_operationMode $gv_fileDialogShortCutTip $gv_browserMode $gSelectNurbsCurvesBit $gSelectNurbsSurfacesBit $gSelectCurvesOnSurfacesBit $gSelectMeshesBit $gSelectCVsBit $gSelectHullsBit $gSelectEditPointsBit $gSelectCurveParmPointsBit $gSelectCurveKnotsBit $gSelectSurfaceParmPointsBit $gSelectSurfaceKnotsBit $gSelectSurfaceRangeBit $gSelectSurfaceEdgeBit $gSelectIsoparmsBit $gSelectNurbsFaces $gSelectMeshVerts $gSelectMeshEdge $gSelectMeshFaces $gSelectMeshUVs $gSelectMeshVtxFaces $gSelectXYZLocators $gSelectOrientationLocators $gSelectUVLocators $gSelectDimensions $gSelectLatticePoints $gSelectParticles $gSelectJointPivots $gSelectScalePivots $gSelectRotatePivots $gSelectSelectHandles $gSelectSubdivSurface $gSelectSubdivMeshPoints $gSelectSubdivMeshEdges $gSelectSubdivMeshFaces $gIprTuningPaused $gFilterUICustomObjectFilterList $gFilterUICustomAttributeFilterList $gObjTypeFiltersLocalized $gUIObjTypeFiltersLocalized $gUIFiltersLocalized $gTotalObjTypeFiltersLocalized $gTotalObjTypeFilters $gObjTypeFilterValuePreset1 $gObjTypeFilterValuePresetAll $gObjTypeFilterValuePresetNone $gEditorCheckBoxPaths $gTabCheckBoxPaths $gPluginObjectTypeFilterParents $gFilterUIDefaultObjectFilterList $gFilterUIDefaultAttributeFilterList $gFilterUIViewList $gFilterUIPluginCustomObjectFilterList $gFilterUIPluginCustomObjectFilterTypeList $gFilterUIPluginCustomObjectFilterTextList $gFilterUIPluginCustomObjectFilterNameList $gFilterUIPluginCustomObjectFilterInsertBelowList $gFilterUIPluginCustomObjectFilterRegCountList $gMainPane $savedHypergraphPanelStates $savedHypergraphPanelNames $doRestoreHypergraphSettings $dpToolbar $gDynPaintEdCreatedFirstTime $gDynPaintEditorName $gBrushShelfTopLevel $gSelect $gDynSelectTool $gCurrentDynFileName $gSavedAsOnce $gPEXSizeField $gPEYSizeField $gCurrentDynEditor $imgExt $imfKey $imfPlugInExt $imfPlugInKey $dynAutoSaveToggle $gOptionBox $gCreatorWireCtx $paintEffectsSetSizeWin $dynPixelPaintToggle $dynRadRefreshOff $dynRadRefreshWire $dynRadRefreshRendered $dynSelOnlyToggle $dynRefreshMode $dynUsePressureToggle $gDynPaintMenusFirstTime $dynPaintSceneToolsToolbox $dynPaintCanvasToolsToolbox $dynPaintTubeTools $dynPaintLeafTools $dynPaintFlowerTools $dynPaintBudTools $dynPaintToolbar $gDirRetainingOptionVar $imgEXRCompression $imgEXRPixelType $imfPlugins $gOptionBoxActionToolItem $gOptionBoxActionToolItemCB $gOptionBoxEditMenu $gOptionBoxEditMenuToolItem $gOptionBoxEditMenuActionItem $gOptionBoxEditMenuSaveItem $gOptionBoxEditMenuResetItem $gOptionBoxHelpItem $gOptionBoxTabLayout $gOptionBoxApplyAndCloseBtn $gOptionBoxApplyBtn $gOptionBoxResetBtn $gOptionBoxCloseBtn $gOptionBoxSaveBtn $gOptionBoxOptions $gOptionBoxHelpTag $gLastUsedOptionBoxOptions $gHyperShadeSelectedBinList $gFilterUIMenuList $gFilterUIPopupMenuList $gFilterUIFieldList $gFilterUIFilterStatusControlList $gFilterUIObjectSelectionFilterList $gFilterUIAttributeSelectionFilterList $gFilterUIImplicitFilterList $gFilterUIRelatedFiltersProcedureList $gFilterUIRelatedAttrFiltersProcedureList $level $gLastObjectFilterCount $gLastAttrFilterCount $gLastRenderFilterCount $gLastUnknownFilterCount $gFilterUISelectedAttributes $gFilterUISelectAttributesCheckboxes $gChannelBoxName $gCustomSelPriorityCount $gFastInteraction $state $gGridSpacingDefault $gGridDivisionsDefault $gGridSizeDefault $gGridDisplayAxesDefault $gGridDisplayGridLinesDefault $gGridDisplayDivisionLinesDefault $gGridDisplayGridPerspLabelsDefault $gGridDisplayGridOrthoLabelsDefault $gGridDisplayAxesAccentedDefault $gGridDisplayPerspLabelPositionDefault $gGridDisplayOrthoLabelPositionDefault $gRefreshMode $kDefaultStitchSurfaces $kDefaultTrimDisplay $kDefaultLattices $kDefaultLatticeResolution $kDefaultGlobalLatticeResolution $gHelpObjectArray $gHelpProcNameArray $prefWndScriptJob $gPrefsCustomTabCreate $gPrefsCustomTabTitles $gPrefsCustomTabNames $gPrefsCustomTabFrameCreate $gNodeEdGlobalOptionsKeys $gCustomSelPriorityHold $gPrefsCustomTabHoldCurrentState $gMayaMode $gUseHelpBrowserWin $gRaiseHelpBrowserWin $gPrefsCustomTabCtrlUpdate $gShelfCreated $gGuiStartupTime $gBuffStr $gBuffStr0 $gBuffStr1 $gBuffStrArr $gLastAction $gCurrentWorkingFrame $gHelpBrowserWinID $gUIpathDiv $gMainWindowForm $gStatusLineForm $gShelfForm $gWorkAreaForm $gToolboxForm $gTimeSliderForm $gPlaybackRangeForm $gCommandLineForm $gHelpLineForm $gAttributeEditorForm $gToolSettingsForm $gChannelsLayersForm $gChannelsForm $gLayersForm $gMayaLiveControlForm $gStatusLineVisible $gShelfVisible $gToolboxVisible $gTimeSliderVisible $gPlaybackRangeVisible $gCommandLineVisible $gHelpLineVisible $gAttributeEditorVisible $gToolSettingsVisible $gChannelsVisible $gLayersVisible $gUIElementsRestored $gShowAllUIElements $gHideAllUIElements $gLasso $gPaintSelect $gMove $gRotate $gScale $gXformManip $gMoveNormal $gTransform $gMoveLimits $gRotateLimits $gScaleLimits $gPropMod $gPolyNormEdit $gshowManip $gSoftMod $gPolyshortestEdgePath $gSoftSelectOptionsCtx $gPanZoomCtx $gMainHelpMenu $gPreviousMenuMode $gMenuModeButton $gMainFileMenu $gMainEditMenu $gMainModifyMenu $gMainDisplayMenu $gMainWindowMenu $gMainCreateMenu $gMainAssetsMenu $gMainKeysMenu $gMainHumanIKMenu $gMainSkeletonsMenu $gMainDeformationsMenu $gMainSkinningMenu $gMainConstraintsMenu $gMainCharactersMenu $gMainGeoCacheMenu $gMainEditDeformationsMenu $gPolygonsSelectMenu $gPolygonsMeshMenu $gPolygonsEditMeshMenu $gPolygonsMeshToolsMenu $gPolygonsProxyMenu $gPolygonsNormalsMenu $gPolygonsColorMenu $gPolygonsCreateUVsMenu $gPolygonsEditUVsMenu $gMainEditCurvesMenu $gMainSurfacesMenu $gMainEditSurfacesMenu $gMainSubdivSurfacesMenu $gMainDynSettingsMenu $gMainParticlesMenu $gMainFluidsMenu $gMainFluidsCacheMenu $gMainHairMenu $gMainFieldsMenu $gMainDynBodiesMenu $gMainDynEffectsMenu $gMainNMeshMenu $gMainNParticleMenu $gMainEffectsAssetsMenu $gMainShadingMenu $gMainRenTexturingMenu $gMainRenderMenu $gMainCartoonMenu $gMainCreatorMenu $gHfHairMenu $gMainStereoMenu $gMainNConstraintMenu $gMainNCacheMenu $gMainNSolverMenu $gClothCreateMenu $gClothSimMenu $gClothConstraintMenu $gModelingMenus $gPolygonsMenus $gAnimationMenus $gDynamicsMenus $gRenderingMenus $gNDynamicsMenus $gMainOptionsMenu $gMainPrimitivesMenu $gMainCurvesMenu $gRenderHairMenu $gMainLightingMenu $gSelectionMaskInitial $gSelectionMaskStack $gUIComponentToolBarArray $kNameIndex $kControlIndex $kToolBarElementSize $gUIComponentDockControlArray $kDockControlElementSize $gUIComponentBarArray $gUIComponentBarComponentArray $kComponentCountIndex $kComponentBarElementSize $kComponentElementSize $kCallbackIndex $kLayoutIndex $kPositionIndex $kCurrentIndex $kParentIndex $kCloseButtonIndex $gAttributeEditorButton $gToolSettingsButton $gChannelsOrChannelsLayersButton $gLayerEditorButton $gAEDeferredUpdate $gFlyThroughLastPosition $gFlyThroughRotation $gFlyThroughAnchor $greasePencilCloseWindowScriptJobId $greasePencilPreButtonChangeScriptJobId $greasePencilPostButtonChangeScriptJobId $size512String $size1024String $size2048String $currentGreasePencilColorValue $gEditDeleteAllByTypeSubMenu $gEditSelectAllByTypeSubMenu $presetBlendMenu $gPresetBlending $gAEFocusNode $gAENotesScriptJob $gAENotesScriptJob2 $gAENotesScriptJob3 $gAENodeStack $gAttributeEditorWindowName $gAEMenuBarLayoutName $gAERootLayoutName $gAERootPaneLayoutName $gAENothingSelectedLayout $gAEBaseLayoutName $gAECurrentTab $gAERelatedNodes $gAETabLayoutName $relationshipEditorPulldownMenu $relationshipEditorRegisterCB $relationshipEditorUnregisterCB $uvMainLinkMenu $furUVLinkMenuItem $hairFurLinkMenuItem $gMiInteractionEditorMenuParent $gMiInteractionEditorMenuAfter $gAEStackLayout $gAEHeaderLayoutName $gAEControlLayoutName $gLastViewedAEType $gAutoUpdateAttrEdFlag $gRelatedNodes $gAEPrevCurrentTab $gAETabMarker $gAESelectionScriptJob $gAEConstructionScriptJob $gAEColorMgtEnableChangedScriptJob $gAEColorMgtWorkingSpaceChangedScriptJob $gAEColorMgtPrefsViewTransformChangedScriptJob $gAEColorMgtConfigChangedScriptJob $gAEColorMgtUserPrefsChangedScriptJob $gAERenamingNode $gIgnoreAEUpdate $gAErenderGlobalsQualityLUT $gAErenderGlobalsResolutionLUT $gAEIKHandleMenus $gTransformLimitsUILUT $gAEmotionPathWorldUpWidgets $gAEmotionPathFollowCBG $gAEaimConstraintWorldUpWidgets $gAEnormalConstraintWorldUpWidgets $gAEtangentConstraintWorldUpWidgets $gAttributeEditorNodeTypeArray $gAttributeEditorHelpCommandArray $gTextColumnWidthIndex $gAENameTextFieldIndex $gStandardWindowWidthIndex $gObjectsDRA $gRenameFieldChanged $gRenameAttrWin $gRenameAttrEnumScrollList $gRenameAttrEnumTextGrp $gRenameAttrEnumText $gDynRenameAttrUpdateJob $gObjectsDDA $gDeleteAttrWin $gDynDeleteAttrUpdateJob $gAttrTypeDAA $gObjectsDAA $gDataTypeDAA $gScalarAryDAA $gParticleModeDAA $gAddAttrWin $gAddAttrEnumScrollList $gAddAttrEnumTextGrp $gAddAttrEnumText $gDynAddAttrUpdateJob $gTypesWithSwatch $gAttrEnumAttribute $gAttrEnumNewValues $gAEAttrPresetCurrentTarget $gAEAttrPresetBlend $gDefaultTemplateLabelWidth $gDefaultTemplateLabelOffset $gDefaultTemplateSingleWidgetWidth $gDefaultTemplateExtraWidth $gAttributeEditorTemplateLabelWidth $gAttributeEditorTemplateLabelOffset $gAttributeEditorTemplateSingleWidgetWidth $gAttributeEditorTemplateExtraWidth $kSingleWidgetWidthIndex $kTextColumnWidthIndex $gStandardIdent $gStandardWidgetAreaIndex $gOptionBoxTextColumnWidthIndex $gChannelBoxWidgetWidthIndex $gChannelBoxWidgetHeightIndex $gAESingleWidgetWidthIndex $gAEMapButtonIndex $gTemplateColorSwatchOffset $gTemplateOptionMenuOffset $gTemplateCheckBoxOffset $gOptionsTemplateLabelWidth $gOptionsTemplateLabelOffset $gOptionsTemplateControlAreaWidth $gOptionsTemplateExtraWidth $gOptionsTemplateExtraLabelOffset $gOptionBoxTemplateDescriptionMarginWidth $gOptionBoxTemplateFrameSpacing $gOptionBoxTemplateFrameMarginHeight $gOptionBoxTemplateFrameMarginWidth $gOptionBoxTemplateInnerFrameMarginHeight $gOptionBoxTemplateInnerFrameMarginWidth $gOptionBoxTemplateTextColumnWidth $gOptionBoxTemplateSingleWidgetWidth $gOptionBoxTemplateSliderWidgetWidth $gOptionBoxTemplateOffsetText $gToolOptionBoxTemplateDescriptionMarginWidth $gToolOptionBoxTemplateFrameSpacing $gToolOptionBoxTemplateFrameMarginHeight $gToolOptionBoxTemplateFrameMarginWidth $gToolOptionBoxTemplateInnerFrameMarginHeight $gToolOptionBoxTemplateInnerFrameMarginWidth $gToolOptionBoxTemplateLabelWidth $gToolOptionBoxTemplateLabelOffset $gToolOptionBoxTemplateControlAreaWidth $gToolOptionBoxTemplateExtraWidth $gToolOptionBoxTemplateExtraLabelOffset $gToolSettingsMainWindowLocation $gToolSettingsMainWindowIcon $gToolSettingsMainWindowName $gToolSettingsMainWindowResetButton $gToolSettingsMainWindowHelpButton $gToolSettingsSeparateWindowLocation $gToolSettingsSeparateWindowIcon $gToolSettingsSeparateWindowName $gToolSettingsSeparateWindowResetButton $gToolSettingsSeparateWindowHelpButton $gIgnoreLEUpdate $gChannelBoxForm $gChannelButtonForm $gLayerEditorForm $gChannelsLayersPane $gChannelsLayersWidth $gChannelFcurveEdSyncCallback $gChannelsWidth $gOldFloat $gAddObjectsMenuItemForAnimLayers $gAddObjectsOptionsMenuItemForAnimLayers $gRemoveObjectsMenuItemForAnimLayers $gSelectObjectsMenuItemForAnimLayers $gSelectBranchMenuItemForAnimLayers $gSelectLayerNodeMenuItemForAnimLayers $gExportLayerMenuItemForAnimLayers $gExportBranchMenuItemForAnimLayers $gMememberShipMenuItemForAnimLayers $gAttributeEditorMenuItemForAnimLayers $gDeleteSelectedLayerMenuItemForAnimLayers $gDeleteEmptyLayersMenuItemForAnimLayers $gDeleteMenuItemForAnimLayers $gLayerModeMenuItemForAnimLayers $gLayerRotationAccMenuItemForAnimLayers $gLayerScaleAccMenuItemForAnimLayers $gSelectedAnimLayers $gColorPickerWindow $gRenderLayerEditorSelectColorOne $gRenderLayerEditorSelectColorTwo $gLayerEditorCurrentLayerUpdateFromSelection $gRenderPassPresetPath $gCurrentLayerEditor $gLayerEditorLastButtonSelection $gMasterLayerRendererName $gPassesTabPassSelectionOverride $gUpdateRenderPassesRenderableStateOverride $gPassesTabPassContributionMapSelectionOverride $relationshipEditorNameListLocalized $relationshipEditorNameList $furUVLinkShapeNode $pfxUVLinkShapeNode $hairUVLinkShapeNode $gPrevNumKeys $gRelationshipsChangedScriptJobNumber $gDisplayLayerManagerChangedScriptJobNumber $gRenderLayerManagerChangedScriptJobNumber $gAnimLayerChangedScriptJobNumber $MiInteractionFilterNodes $expose_facade_nodes $gPatchNotesExistState $gLayersWidth $gIsMarkingMenuOn $gScriptEditorPanel $gSeqEdUpdateScriptJob $seqPlayBackwardsButton $seqPlayButton $gShotPlaylistShots $gShotPlaylistShotWidgets $gGraphEditorTanButtonNames $gGraphEditorPopupMenuName $gUnisolatedCurves $gNodeEditorSavedPanelStates $gCreateNodePanelInitDone $gKeepHyperGraphWhileClosingWindow $gHeatMapAutoUpdateJob $gHeatMapMax $gFirstHypergraph $gRenderCreateBarIconsAndTextMinWidth $gRenderCreateBarIconsAndTextMaxWidth $gPreviousFilterBox $gPreviousFilterButton $gButtonsColumnWidth $gHyperShadePanelLookupTable $gHyperShadePanelLookupTableCreated $gHypershadePluginCallbacksRegistered $hsInConstruction $gVisorPanelLookupTable $gVisorPanelLookupTableCreated $gVisorPanelCreatedThisSession $gTextureEditorMenubarPrefix $gTextureEditorPopupType $rvToggleGamma $rvToggleExposure $rvSavedGammaValue $rvSavedExposureValue $rvGammaMinRange $rvGammaMaxRange $rvExposureMinRange $rvExposureMaxRange $mrImrResolution0 $mrImrResolution1 $mrImrCamera $gRenderViewRenderTarget $gRenderViewRenderTargetNameChangeJob $gRenderViewRenderTargetDeletedJob $gRenderViewRenderTargetNormal $gRenderViewRenderTargetInNameChange $gRenderViewRenderTargetInDelete $gRenderPassLockUnlockImage $gRenderViewRenderAborted $gRenderTargetForceDependenciesRender $renderViewShadowsMode $renderViewGlowPassMode $renderViewResolutions $gRenderViewLastRenderCamera $gRenderViewLastRenderLayer $gRenderViewLastRenderTime $bdeNumUdAttrsUsed $bdeBinaryMode $bdeDiscreteValueMode $bdeDiscreteRangeMode $bdeHexSetMode $bdeHesNotSetMode $bdeHesEqualMode $bdeContinuousMode $bdeAsColorMode $bdeDiscreteValName $bdeDiscreteRangeName $bdeHexValName $bdeContinuousName $bdeAsColorName $bdeTPresetLayout $bdeQueryColorLayout $bdeVSSJ $bdeHexNotSetMode $bdeHexEqualMode $bdeEditingTemplate $bdeCurrTab $bdeBrushToolCtx $gEditorList $gDefaultConnection $gNodeEditorWindowPanels $fromAttr $toAttr $outliner $hyperBookmarks $hyperBookmarksInitialized $gGraphUILookupTable $gGraphUILookupTableCreated $gLibraryUILookupTable $gLibraryUILookupTableCreated $gCollectionUILookupTable $gCollectionUILookupTableCreated $gCreateRenderNodeWindowTreeLister $gCreateRenderNodePluginCallbacksRegistered $mayaNodeTypeInfo $WantProtein $gHyperShadeTabTypes $gFilteredCollectionLookupTable $gFilteredCollectionLookupTableInit $uvEntryFieldU $uvEntryFieldV $gUVEntryTransformMode $gUVvalues $gPreviousUVvalues $gUVcopyValues $gUVTexEditToolBar $gFileOptionsString $gOptBoxForm $currentCharacterState $gMinorNodes $gCleanUpProgressReporting $gMainProgressBar $gCleanUpInterrupted $noHyperShadeRefreshForBinRename $gLstRefNode $gReferenceEditorPanel $gReplaceReferenceNode $gAddProxyNode $gPresetBrushShadeBlendHold $gPresetBrushShapeBlendHold $gPresetBlendingHold $gPresetBrushShadeBlend $gPresetBrushShapeBlend $gUseBlendBrush $gIsPost5Preset $gIsPost7Preset $gIsPreCurlPreset $gHasADefinedTextureFlowValueFalse $gPresetBlenderBrush $gPresetTargetBrush $gPresetNewNode $gLoadedOGS $gAllOptionStrings $gLastOptionSelectionIndex $gLastOptionSelection $gCurrentOptionSelection $gFileOptionTreeViewName $gMergeOptionValue $namespaceRadioCollectionName $gCurrentFileDialogSelection $rightWin $leftWin $postCommand $windowMode $connectWinLeftLabel $connectWinRightLabel $gHyperShadeLastBinButtonSelectionIndex $gHyperShadeLastBinNameNum $gPinnedContainerForTemplateAssign $gRegisteredTreeViewNames $gRegisteredTreeViewModes $gDynRelEditorPaneScriptJob $gDynRelEditor $gCurrDynConnections $gLstRefFile $gOutlinerPopupMenu $categoryName $categoryInsertAfter $categoryCmd $gSelectedAssemblyNodes $gReferenceEditorOutliner $gRefEdViewportCamera $gReferenceEditorModelEditor $gProxyMultiSwitchRefNodes $supportHWshadows $gScriptEditorMenuBarPrefix $showLineNumbersMenuItemSuffix $useTabsForIndentMenuItemSuffix $autoCloseBracesMenuItemSuffix $commandCompletionMenuItemSuffix $pathCompletionMenuItemSuffix $toolTipHelpMenuItemSuffix $showQuickHelpMenuItemSuffix $batchRenderMsgsMenuItemSuffix $echoAllCmdsMenuItemSuffix $errorLineNumsMenuItemSuffix $stackTraceMenuItemSuffix $suppressResultsMenuItemSuffix $suppressInfoMenuItemSuffix $suppressWarningsMenuItemSuffix $suppressErrorsMenuItemSuffix $suppressStackTraceMenuItemSuffix $historyFilterNoneMenuItemSuffix $historyFilterMELMenuItemSuffix $historyFilterPythonMenuItemSuffix $executerBackupFileName $gCommandLayout $gCommandExecuterTabsForm $gCommandReporter $gScriptEditorMenuBarVisible $gCommandExecuterShowQuickHelp $gCommandExecuter $gLastFocusedCommandReporter $gLastFocusedCommandExecuter $gLastFocusedCommandControl $gCommandExecuterTabs $gCommandPopupMenus $gCommandExecuterSideBarHelpField $gCommandExecuterSideBarHelpResults $gCommandExecuterSideBar $gCommandExecuterSideBarHelpForm $gCommandExecuterSearch $gCommandExecuterName $gCommandExecuterLayout $gCommandExecuterType $gCommandExecuterGoto $gCommandExecuterHistory $gStatusLine $gTextualInputField $gNumericalInputXField $gNumericalInputYField $gNumericalInputZField $gSelMarkerFilterTypeList $gSelJointFilterTypeList $gSelCurveFilterTypeList $gSelSurfaceFilterTypeList $gSelDeformerFilterTypeList $gSelDynamicFilterTypeList $gSelRenderingFilterTypeList $gSelOtherFilterTypeList $gSelMarkerMenuLabelList $gSelJointMenuLabelList $gSelCurveMenuLabelList $gSelSurfaceMenuLabelList $gSelDeformerMenuLabelList $gSelDynamicMenuLabelList $gSelRenderingMenuLabelList $gSelOtherMenuLabelList $makeLiveLastSurfaceNameFields $makeLiveButton $makeLiveTextField $makeLiveSurfaceNameField $defaultTextBGC $gModelingToolkitButton $gAnimationSelectionMasksOn $gNURBSelectionMasksObjects $gNURBSelectionMasksComponents $gDeformersSelectionMasksObjects $gDeformersSelectionMasksComponents $gRenderingSelectionMasksObjects $gRenderingSelectionMasksComponents $gAllObjects $gAllComponents $hbInited $tslMenuSets $tslMenus $tslAllMenus $gTimeSliderTimeField $gPlayBackForwardButton $gPlayBackReverseButton $gTimeRangeSlider $gCommandLine $gCommandLineSourceButton $gShelfTopLevel $gShelfCollection $InternalShelfLabels $gMainAuxButton $gMainAuxText $kNumberOfQuickLayoutButtons $kQuickLayoutInfoArrayElementSize $kImageIndex $kCommandIndex $kAnnotationIndex $kContentFrameSize $gToolBox $gNonSacredToolWidget $gCurrentSacredTool $gQuickButtonArray $gPanelEditorWnd $dynMaxFloatField $dynMinFloatField $polyTextureColorShader $longueurNorm $point $facet $edgeDisp $backCull $colShaded $colChannel $matBlend $polyLastTool $gPropModAnimCurvePrefix $gStartWithAutoComplete $gOneClickDefaultSendPreviousSelection $gOneClickDefaultSendEntireScene $gLastHiddenSelection $gHeadsUpDisplayMenu $gToggleOriginAxis $gShowGrid $gJointDisplayScale $gDisplayHideSubmenu $gDisplayShowSubmenu $gDisplayPerCameraVisibilitySubmenu $gDisplayPolygonsSubmenu $gDisplayNurbsSubmenu $gDisplaySubdivSubmenu $gDisplayAnimationSubmenu $gDisplayRenderingSubmenu $gHideClothItem $gHideFurItem $gShowClothItem $gShowFurItem $gHUDupdateIKScriptJobExists $gHUDupdateIKScriptJob $parentPopupMenu $walkToolMessage $globalScreenSliderMode $gCamera $pbDisplayMenus $gModelEditorSelectCameraMenuItem $gModelEditorSelectCameraSetMenuItem $modelPanelShowMenus $autoAddNewObjJobNum $ModelPanelToolBarV2ScriptJob $menusOkayInPanels $editorName $panelName $gPreFileCmdCallbackTool $gPreFileCmdCallbackPlayState $gQuadDrawClearDots $FileDialogFilterTypes $nexIconPath $nexRefreshCmd $nexSymText $nexSymName $nexSymBtn $prevSlideType $prevSlideMesh $nexSlideText $defaultFieldBgColor $nexPickSelConstText $selConstField $nexPickRelaxAffectsText $nexPickExtendText $dRModeBtns $nexLastSnapManipType $nexLastMoveManipMode $nexLastMoveManipHandle $nexHandleX $nexHandleY $nexHandleZ $nexHandleXY $nexHandleYZ $nexHandleXZ $nexHandleXYZ $gMTSuperContext $nexLastSelectionMode $dRCompBtnCount $gdRCompBtns $gdRCompBtns_Names $gDRPreferenceWindow $nexLastSelType $nexComponentCountLabel $nexRightPanel $nexLeftPanel $nexFloatWin $nexFloatForm $gDRBottomPane $nexPanelMenuCont $DRPrefWndScriptJob $cutColorLineSlider $cutColorVertSlider $cutColorEdgeSlider $cutColorFaceSlider $locksFrame $softSelFrame $transformFrame $drTFormLayout $drOptionPanel $drQuaDrawPanel $drConnectFormLayout $drBridgeFormLayout $drVertChamferFormLayout $drVertExtrudeFormLayout $drFaceExtrudeFormLayout $drBevelFormLayout $drCutFormLayout $drTargetWeldFormLayout $drSoftSelDistType $gdRpanel $gdRPanes $gDRTopPane $gdRCompBtns_Cmds $gdRCompBtns_Ann $gdRCompBtns_Images $nexPowerButton $gDRTopPaneComponentsFrame $drSlideRB $drSegRadio $drPinchRadio $drSlideField $drConnSegField $drConnPinchField $gNexContext $nexScrollForm $gtransformCoordMT $gNonSacredTool $gHIKDockableWindowWidth $gHIKScrollBarWidth $gHIKCurrentCharacter $gHIKCurrentSource $gHIKSeparatorWidth $gHIKSkeletonTabHeight $gHIKDefinitionTabHeight $gHIKRigAspectRatio $gHIKRigTabsAuxWidth $gHIKDockMinWidth $gHIKSchematicWidgetMinWidth $gHIKDockSkeletonDefinitonWidth $gHIKControlRigFrameLayoutHeight $gHIKControlRigCollapseExpandHeightDiff $gHIKControlRigAuxHeight $gHIKCustomRigFrameLayoutHeight $gHIKCustomRigCollapseExpandHeightDiff $gHIKCustomRigAuxHeight $hikStrSkeleton $hikStrControlRig $hikStrCustomRig $hikStrReset $hikStrLiveConnection $hikStrIK $hikStrFK $hikStrHIKDefinition $hikStrEditProperties $hikStrResetProperties $hikStrMirrorMatching $hikStrConfirugreMirrorMatching $hikStrRigLook $hikStrWire $hikStrStick $hikStrBox $hikStrStancePose $hikStrRigAlign $hikStrImportMapping $hikStrExportMapping $hikStrBakeToCustomRig $hikStrBakeCustomRig $hikStrBakeLiveToCustomRig $hikStrControls $hikStrCreate $hikStrDefine $hikStrDelete $hikStrDeleteControlRig $hikStrDefinition $hikStrLockDefinition $hikStrRename $hikStrMapBones $hikStrExtractMapTemplate $hikStrStance $hikStrOK $hiktStrCancel $hikStrUnknown $hikStrNone $hikStrMapTranslation $hikStrMapRotation $hikStrBakeToSkeleton $hikStrBakeSkeleton $hikStrBakeLiveToSkeleton $hikStrBakeToControlRig $hikStrBakeControlRig $hikStrBakeRigBodyPart $gHIKneedSyncOnSetKeyframe $gCustomRigUndoId $gCustomRigRedoId $characterizeFileNewScriptJobId $characterizeFilePostSceneReadJobId $hikBakeToControlRigLayer $hikPreBakeAlignState $miEnableExtensions $miEnableDebugScripts $miUserInterfaceCheck $miUserInterfaceVersion $miUserInterfaceVerbosity $miTimerEnable $miTimerValue $miCreateJobID $miMemoryLowerLimit $gMiUserInterfaceVerbosityScriptJobIsSet $StringOptionNames $StringOptionTypes $StringOptionDefaults $gMiStringOptRastMotionFactorIndex $gMiStringOptRastTranspDepth $gMiStringOptRastUseOpacityIndex $gMiStringOptImpStateIndex $gMiStringOptImpDensityIndex $gMiStringOptImpMergeIndex $gMiStringOptImpTraceDepthIndex $gMiStringOptImpTraverseIndex $gMiStringOptShadowMapPSIndex $gMiStringOptAOStateIndex $gMiStringOptAORaysIndex $gMiStringOptAOCacheIndex $gMiStringOptAODensityIndex $gMiStringOptAOCachePointsIndex $gMiStringOptIPStateIndex $gMiStringOptIPRaysIndex $gMiStringOptIPInterpolateIndex $gMiStringOptIPInterpointsIndex $gMiStringOptIPIndirectPassesIndex $gMiStringOptIPScaleIndex $gMiStringOptIPEnvIndex $gMiStringOptIPEnvRaysIndex $gMiStringOptIPEnvScaleIndex $gMiStringOptIPRebuildIndex $gMiStringOptIPMapFileIndex $gMiStringOptGeomDispMotionFactIndex $gMiStringOptContrastAllBuffersIndex $gMiStringOptFGNormalToleranceIndex $gMiStringOptTraceCameraClipIndex $gMiStringOptUnifiedSamplingIndex $gMiStringOptSamplesQualityIndex $gMiStringOptSamplesMinIndex $gMiStringOptSamplesMaxIndex $gMiStringOptSamplesErrorCutoffIndex $gMiStringOptSamplesPerObjectIndex $gMiStringOptProgressiveIndex $gMiStringOptProgressiveMaxTimeIndex $gMiStringOptProgressiveSubsamplingSizeIndex $gMiStringOptIRayIndex $gMiStringOptLightRelativeScaleIndex $gMiStringOptTraceCameraMotionVectorsIndex $gMiStringOptRayDifferentialsIndex $gMiStringOptEnvironmentLightingModeIndex $gMiStringOptEnvironmentLightingQualityIndex $gMiStringOptEnvironmentLightingShadowIndex $gMiStringOptEnvironmentLightingResolutionIndex $gMiStringOptEnvironmentLightingShaderSamples $gMiStringOptEnvironmentLightingScale $g_mrHelpMenuItem $gMrBakeOptionBox $temporaryBakeSetOverride $mrNodeTypeInfo $gMiScanlineLastValueForLegacyAdaptive $gMiSamplesPerObjectLastValueForNonUnified $miPresetsFiltering $miHintsFiltering $miPresetsRasterizer $miOptions $miPresetsAcceleration $miGlobals $miPresetsShadowMaps $miHintsShadowMaps $miLastActiveShadowMethod $miPresetsRaytracing $miHintsRaytracing $gMentalRayUIEnabled $mrMapVizWindowName $mrMapVizWindowParentWidget $mrMapVizWindowUISetup $miStartFile $miDefaultStartFile $miFactoryVerbosity $miFactoryIdAction $miImfkeyOverrideScriptJobNum $surfaceSamplingFirstOutputMap $surfaceSamplingOutputArraySize $igNullDescriptionTag $igCurrentDescription $igBrushList $igActiveBrush $igNewActiveBrush $igBrushMagnitude0 $igBrushMagnitude1 $igBrushMagnitude2 $igBrushMagnitude3 $igBrushMagnitude4 $igBrushMagnitude5 $igBasepath $MdGUOrigSelection $MdGUSelection $MdGUUseLocator $MdGULocator $MdGUCLoadSelection $MdGeoUtilsContextCB $GUObject $GUAngleBetween $GUObjectRadius $MdTileSubdECDisplayAxes $MdTileSubdECSelection $MdTileSubdECTiles $MdTileSubdECTileInfo $MdTileSubdECTileInfoParent $MdTileSubdECCB $ContextSL $igIconDir $g_ptexBakeColorsStartJob $g_ptexBakeColorsStopJob $g_ptexBakeCurrentMesh $g_ptexBakeCurrentColorSet $g_ptexBakeFile $g_ptexBakeTextureStartJob $g_ptexBakeTextureStopJob $g_ptexBakeCurrentTexture $g_ptexBakeTpu $muQuitScriptJob $muButtons $gMdToolRegistry $gMdRemoveToolsQuitAppSJ $xgmUseHandler $dlUseSceneNavigator $xgmGuideAttrList $xgmFXProxyGroup $sourceFile $isOpeningScene $xgmPreImportPalettes $xgmDynamicGuidesGroup $xgmGroomGroup $xgmCVSToolCheckArray $xgmCVSToolN $xgmRegionMapDir $xgmCopyCurve $xgmCopyGuide $xgmCopyGuideType $xgmDynamicGuidesToolCreate $xgmDynamicGuidesToolAccept $xgmDynamicGuidesToolCancel $helpDynamicGuidesTool $xgmDynamicGuidesToolCurvesFromGuides $xgmGuideCheckMultiEntries $xgmGuideCheckNumMultiEntries $guideReshapeCurves $controlCurves $xgmLatticeToolGuideList $xgmLatticeToolNcvList $xgmLatticeToolBeforePos $xgmTargetGuideToolTarget $xgmTargetGuideToolTargetOrigSG $gxgmTMLookupTable $gxgmTMLookupTableCreated $gxgmTMFramePrefix $cMusclePaint_slots $cMusclePaint_mIdx $cMusclePaint_mode $cMusclePaint_modeStr $cMusclePaint_normalize $cMusclePaint_polyGeo $cMusclePaint_mS $cMusclePaint_mD $cMusclePaint_ForceMS $cMusclePaint_allowSave $cMusclePaint_wtNames $cMusclePaint_wtLabels $cMusclePaint_wtNormalize $cMusclePaint_wtCnt $cMusclePaint_lastMode $cMBld_stretchVals $cMBld_splineDefVals $cMBld_splineVals $cMBld_splineJiggleVals $cMBld_splineCycleVals $cMBld_splineRestVals $cMBld_objectVals $gJob_SelectionChanged $sculptValue $sculptActive $gSelChanged_cMuscleSelf $gArtAttrCurrentAttr $gArtAttrFilterLabel $gArtWorkdirectory $gArtSetAttrMapWorkspace $artSelectObject $gAssemblyNodeNS $gAssemblyRepresentationNS $gAssemblyRepresentationNSChoice $gAssemblyNodeNSTreeView $gSceneAssemblySceneLastDirectory $gSceneAssemblyCacheLastDirectory $gSavedWorkSpace $gEditorNamespaceTreeViewName $gCurrentSelectedNamespaces $gInManuallySelectStatusSetting $currentSelectedNamaespaces $gTmpCacheTimeRangeModes $gTmpSampleLowFrames $gTmpSampleHighFrames $gAllowEditTimeRangeInTable $gAlembicShowRangeAdjustDialog $BifrostGraphEditorName $gMainWindowMenuName $VPEScriptedPanelType $g_OverrideQuitPerformed $gBifrostAttributeEmitters $gBifrostAttributeColliders $gBifrostAttributeAccelerators $gBifrostAttributeKillplanes $gBifrostHUDMenuCheckBoxControl $gBifrostStopBackgroundProcessingMenuItem $gBifrostFlushScratchCacheMenuItem $BifrostGameWatchPanelCategoryName $gBifrostOptionsMenuItem $currentRendererName // 

举个例子,比如这个 add_menu function 这个例子只是加到菜单的最后而已

def add_menu(location='Window->General Editors', label='xxx', command='print "xxx"'):
    '''
    Add menu to specified location in main menu.

    Args:
        location: Window->General Editors.
        label: the label on the menu.
        command: the command
    '''
    # gMainWindowMenu='mainWindowMenu'
    menu_path = location.split('->')

    def get_menu_item(label, parent_menu=None):
        'returns menu item with label in parent_menu'
        menu_item = None

        # if it is top level menu
        for m in mc.lsUI(type='menu'):
            if mc.objectTypeUI(m) != 'commandMenuItem' and mc.menu(m, q=1, l=1) == label:
                menu_item = m

                if parent_menu:
                    if not menu_item in mc.menu(parent_menu, q=1, ia=1) or []:
                        continue
                else:
                    break

        pmc = mc.menu(menu_item, q=1, pmc=1)
        if pmc:
            mm.eval(pmc)

        return menu_item

    parent_menu = None
    for m in menu_path:
        menu_item = get_menu_item(m, parent_menu)
        parent_menu = menu_item

    print parent_menu

    # delete existing menuItem
    if mc.menu(parent_menu, q=1, ia=1):
        for m in mc.menu(parent_menu, q=1, ia=1):
            if mc.menuItem(m, q=1, l=1) == label:
                mc.deleteUI(m)
                break

    mc.setParent(menu_item, m=1)
    mc.menuItem(l=label, c=command)

用法是

# 比如加到File菜单最后一个
add_menu("File",'My Custom Menu','print "From My Custom Menu ..."')

# 又比如加到Window->General Editors下的菜单最后一个
add_menu(‘Window->General Editors‘,‘Python Command Shell’, 'print "From Python Command Shell ..."')

如何加到奇怪的地方

maya_toolbox_icon

上图中的图标来自这里

如何知道具体要加到哪个layout下面呢,这里有个中古时代的神器,虽然很多年没更新了,但是略微改两行还能用,lz准备把他改成pyqt版的,原始出处在highend3d,lz加了些 maya 2015里的新ui名字,放去了github,准备改成pyqt版的,还没写好

最简单粗暴的用法是source之后,直接把菜单加到整个Maya,

guiHelper_addMenuToAll MayaWindow

之后在大部分ui上右击就能看到菜单了,上图中所示的树状结构正是左侧toolbox那一条ui的层级结构和各种layout和control的名字,这样你才好往上继续加自己的按钮

举例

def add_toolbox_menu():
    gridLayout = 'hj_gridLayout'
    if mc.gridLayout(gridLayout, q=1, ex=1):
        mc.deleteUI(gridLayout)

    mc.setParent('flowLayout2')
    size=36
    mc.gridLayout(gridLayout, nc=1, cwh=[size, size])
    mc.setParent(gridLayout)

    global_vars = inspect.getouterframes(
        inspect.currentframe())[-1][0].f_globals
    # global_vars = globals()
    mc.shelfButton(
        i='play.png', c=lambda *x: __import__("pyshell").main(global_vars),w=40)

上面lz先加了个gridLayout,准备把自己加的按钮全放这个layout下面,这样删或者重建的时候方便,然后加了个自己的shelfButton,上面的命令是开最近写的一个小工具pyshell的,见这里

需要注意的是这里的图标尺寸是36×36,lz是如何知道的呢,因为看上面的移动工具

toolButton -q -w moveTool;
// Result: 36 // 

之后你就可以在这个shelfButton上弹出右键菜单,以及使用平时做菜单的各种技能了. 其实ui上还有多处可以加以利用的地方,稍后再行举例

待续 …

Advertisements

发表评论

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / 更改 )

Twitter picture

You are commenting using your Twitter account. Log Out / 更改 )

Facebook photo

You are commenting using your Facebook account. Log Out / 更改 )

Google+ photo

You are commenting using your Google+ account. Log Out / 更改 )

Connecting to %s

%d 博主赞过: