def __add_rigger_control_actions(cls, root_menu, selection): selected_control = luna_rig.Control(selection[-1]) pm.menuItem(p=root_menu, l="Select CVs", rp="W", c=lambda *args: curveFn.select_cvs(), i=fileFn.get_icon_path("cvs.png")) # Adjust shape sub menu adjust_shape_menu = pm.subMenuItem(p=root_menu, l="Shape", rp="N") cls.__add_shape_actions(adjust_shape_menu, selection) pose_menu = pm.subMenuItem(p=root_menu, l="Pose", rp="E") cls.__add_pose_actions(pose_menu, selection) # Component menu cls.__add_component_actions(root_menu, selected_control)
def show( reset=False ): if pm.about(batch=True): print 'menu not available in batch mode.' return else: # -- get things ready for building the menu menu_name = "Impress Example" pm.setParent( MAYA_WINDOW ) if pm.menu( menu_name, exists=True ): if reset: pm.deleteUI( menu_name ) else: main_menu = pm.menu( menu_name, edit=True ) return main_menu if not pm.menu( menu_name, exists=True ): main_menu = pm.menu( menu_name, tearOff=True ) # -- build the menu with main_menu: with pm.subMenuItem( 'Display', aob=True, tearOff=True ): ui.commandMenuItem( performExample )
def _add_context_menu(self): """ Adds a context menu which displays the current context """ ctx = self._engine.context ctx_name = str(ctx) # create the menu object # the label expects a unicode object so we cast it to support when the context may # contain info with non-ascii characters ctx_menu = pm.subMenuItem(label=ctx_name.decode("utf-8"), parent=self._menu_handle) # link to UI pm.menuItem(label="Jump to Shotgun", parent=ctx_menu, command=Callback(self._jump_to_sg)) # Add the menu item only when there are some file system locations. if ctx.filesystem_locations: pm.menuItem(label="Jump to File System", parent=ctx_menu, command=Callback(self._jump_to_fs)) # divider (apps may register entries below this divider) pm.menuItem(divider=True, parent=ctx_menu) return ctx_menu
def _add_app_menu(self, commands_by_app): """ Add all apps to the main menu, process them one by one. """ for app_name in sorted(commands_by_app.keys()): if len(commands_by_app[app_name]) > 1: # more than one menu entry fort his app # make a sub menu and put all items in the sub menu app_menu = pm.subMenuItem(label=app_name, parent=self._menu_handle) # get the list of menu cmds for this app cmds = commands_by_app[app_name] # make sure it is in alphabetical order cmds.sort(key=lambda x: x.name) for cmd in cmds: cmd.add_command_to_menu(app_menu) else: # this app only has a single entry. # display that on the menu # todo: Should this be labelled with the name of the app # or the name of the menu item? Not sure. cmd_obj = commands_by_app[app_name][0] if not cmd_obj.favourite: # skip favourites since they are alreay on the menu cmd_obj.add_command_to_menu(self._menu_handle)
def endMenu(self): with self.menu: if sysutils.inDevMode(): pm.menuItem(divider=True) with pm.subMenuItem(label="Log Level", to=True): pm.radioMenuItemCollection() pm.menuItem(label='Callback', radioButton=(logutils.logSeverity == -1), c=partial(self.setLogLevel, -1)) pm.menuItem(label='Silent', radioButton=(logutils.logSeverity == 0), c=partial(self.setLogLevel, 0)) pm.menuItem(label='Info', radioButton=(logutils.logSeverity == 1), c=partial(self.setLogLevel, 1)) pm.menuItem(label='Debug', radioButton=(logutils.logSeverity == 2), c=partial(self.setLogLevel, 2)) pm.menuItem(label='All', radioButton=(logutils.logSeverity == 3), c=partial(self.setLogLevel, 3)) pm.menuItem(label="Urllib3 Logging", c=setUrllib3LoggingEnabled, cb=False) pm.menuItem(divider=True) pm.menuItem(label="Reload Tools", c=self.reload)
def __add_component_actions(cls, root_menu, selected_control): if not selected_control.connected_component: return pm.menuItem(p=root_menu, l=str(selected_control.connected_component), en=0) # Space switching if selected_control.spaces: spaces_menu = pm.subMenuItem(p=root_menu, l="Spaces") for space_name in selected_control.spaces_dict.keys(): pm.menuItem(p=spaces_menu, l=space_name, c=lambda triggered=True, name=space_name, *args: selected_control.switch_space( selected_control.spaces_dict.get(name))) # Actions callbacks if hasattr(selected_control.connected_component, "actions_dict"): for label, data_dict in selected_control.connected_component.actions_dict.items( ): pm.menuItem( p=root_menu, l=label, c=lambda *args: data_dict.get("callback", cls.__null_cmd) (), i=fileFn.get_icon_path(data_dict.get("icon")))
def __add_transform_actions(cls, root_menu, selection): pm.menuItem( p=root_menu, l="Create locator", rp="E", c=lambda *args: nodeFn.create_locator(at_object=selection[-1]), i="locator.png") # Match position sub menu match_position_menu = pm.subMenuItem(p=root_menu, l="Match", rp="N") pm.menuItem(p=match_position_menu, l="Position", rp="S", c=lambda *args: pm.matchTransform( selection[-1], selection[0], pos=True)) pm.menuItem(p=match_position_menu, l="Rotation", rp="SW", c=lambda *args: pm.matchTransform( selection[-1], selection[0], rot=True)) pm.menuItem(p=match_position_menu, l="Object center", rp="N", c=lambda *args: transformFn.snap_to_object_center( selection[0], selection[1:])) pm.menuItem(p=match_position_menu, l="Components center", rp="W", c=lambda *args: transformFn.snap_to_components_center( selection[:-1], selection[-1]))
def _add_context_menu(self): """ Adds a context menu which displays the current context """ ctx = self._engine.context ctx_name = str(ctx) # create the menu object # the label expects a unicode object so we cast it to support when the context may # contain info with non-ascii characters ctx_menu = pm.subMenuItem(label=ctx_name.decode("utf-8"), parent=self._menu_handle) # link to UI pm.menuItem(label="Jump to Shotgun", parent=ctx_menu, command=Callback(self._jump_to_sg)) pm.menuItem(label="Jump to File System", parent=ctx_menu, command=Callback(self._jump_to_fs)) # divider (apps may register entries below this divider) pm.menuItem(divider=True, parent=ctx_menu) return ctx_menu
def __add_joint_actions(cls, root_menu, selection): pm.menuItem(p=root_menu, l="Joint chain from selection", rp="E", c=lambda *args: jointFn.create_chain( joint_list=pm.selected(type="joint")), i="kinJoint.png") pm.menuItem(p=root_menu, l="Mirror joints", rp="W", c=lambda *args: jointFn.mirror_chain(chains=selection), i=fileFn.get_icon_path("mirrorJoint.png")) # Transform menu transform_menu = pm.subMenuItem(p=root_menu, l="Transform", rp="N") cls.__add_transform_actions(transform_menu, selection)
def __add_animator_control_actions(cls, root_menu, selection): selected_control = luna_rig.Control(selection[-1]) pm.menuItem(p=root_menu, l="Select component controls", rp="E", c=lambda *args: selected_control.connected_component. select_controls()) pm.menuItem(p=root_menu, l="Key component controls", rp="W", c=lambda *args: selected_control.connected_component. key_controls()) # Bind pose sub menu pose_menu = pm.subMenuItem(p=root_menu, l="Pose", rp="N") cls.__add_pose_actions(pose_menu, selection) # Component actions cls.__add_component_actions(root_menu, selected_control)
def _add_context_menu(self): """ Adds a context menu which displays the current context """ ctx = self._engine.context ctx_name = str(ctx) # create the menu object ctx_menu = pm.subMenuItem(label=ctx_name, parent=self._menu_handle) # link to UI pm.menuItem(label="Jump to Shotgun", parent=ctx_menu, command=Callback(self._jump_to_sg)) pm.menuItem(label="Jump to File System", parent=ctx_menu, command=Callback(self._jump_to_fs)) # divider (apps may register entries below this divider) pm.menuItem(divider=True, parent=ctx_menu) return ctx_menu
def show( reset=False ): global scene_menu if pm.about( batch=True ): print 'menu not available in batch mode.' return else: # get things ready for building the menu menu_name = MENU_LABEL.replace( ' ', '' ) if pm.menu( menu_name, exists=True ): if reset: pm.deleteUI( menu_name ) else: main_menu = pm.menu( menu_name, edit=True ) return main_menu pm.setParent( MAYA_WINDOW ) if not pm.menu( menu_name, exists=True ): main_menu = pm.menu( menu_name, tearOff=True, familyImage='burst_family.xpm' ) # build the menu with main_menu: with pm.subMenuItem( 'Display', aob=True, tearOff=True ): commandMenuItem( kx.display.jointCountHUD, checkBox=pm.optionVar.get( 'jointCountHUDVis', False ) ), ''' commandMenuItem(kx.display.particleCountHUD, checkBox=pm.optionVar.get('particleCountHUDVis', False)), commandMenuItem(kx.display.transformCountHUD, checkBox=pm.optionVar.get('transformCountHUDVis', False)), commandMenuItem(kx.display.currentFrameHUD, checkBox=pm.optionVar.get('currentFrameHUDVis', False)), ''' commandMenuItem( kx.display.currentTimeHUD, checkBox=pm.optionVar.get( 'currentTimeHUDVis', False ) ), pm.menuItem( divider=True ), # commandMenuItem(kx.display.cycleBackgroundColors), commandMenuItem( kx.display.cycleGridDisplay ), pm.menuItem( divider=True ), commandMenuItem( kx.display.togglePlaybackSpeed ), commandMenuItem( kx.display.togglePlaybackSnap ), pm.menuItem( divider=True ), commandMenuItem( kx.display.toggleIsolateSelected ), commandMenuItem( kx.display.toggleXRay ), commandMenuItem( kx.display.toggleWireframeOnShaded ), pm.menuItem( divider=True ), commandMenuItem( kx.display.closeWindows ), with pm.subMenuItem( 'Modify', tearOff=True ) as sub_modify: commandMenuItem( kx.modify.cycleMoveMode ), commandMenuItem( kx.modify.cycleRotateMode ), pm.menuItem( divider=True ), commandMenuItem( kx.modify.unfreezeTranslation ) pm.menuItem( divider=True ) with pm.subMenuItem( 'Animation', tearOff=True ) as anim_menu: with pm.subMenuItem( 'Poses', tearOff=True ): commandMenuItem( kx.poses.copyClipboardPose, label='Capture Pose' ), commandMenuItem( kx.poses.applyClipboardPose, label='Apply Pose' ), commandMenuItem( kx.poses.applyClipboardPoseToSelected, label='Apply Pose To Selected' ), commandMenuItem( kx.poses.mirrorClipboardPose, label='Mirror Pose' ), pm.menuItem( divider=True ), commandMenuItem( kx.poses.openPoseManagerWindow, label='Pose Manager Window...' ), pm.menuItem( divider=True ) with pm.subMenuItem( 'Curves', tearOff=True ): commandMenuItem( kx.animation.smoothTangentIn ), commandMenuItem( kx.animation.smoothTangentOut ), pm.menuItem( divider=True ), commandMenuItem( kx.animation.flipCurve ), commandMenuItem( kx.animation.mirrorCurve ), commandMenuItem( kx.animation.reverseCurve ), commandMenuItem( kx.animation.general.loopCurveFirst ), commandMenuItem( kx.animation.general.loopCurveLast ), pm.menuItem( divider=True ), commandMenuItem( kx.animation.offsetKeyframesUp360 ), commandMenuItem( kx.animation.offsetKeyframesDown360 ), pm.menuItem( divider=True ), commandMenuItem( kx.animation.toggleInfinityCycle ), pm.menuItem( divider=True ), commandMenuItem( kx.animation.keyTickSpecialOn ), commandMenuItem( kx.animation.keyTickSpecialOff ) with pm.subMenuItem( 'Reset IK', tearOff=True ): commandMenuItem( kx.animation.resetIk, ( True, False ), label='T', annotation='Reset translation of selected IK control(s)' ), commandMenuItem( kx.animation.resetIk, ( False, True ), label='R', annotation='Reset rotation of selected IK control(s)' ), commandMenuItem( kx.animation.resetIk, ( True, True ), label='T/R', annotation='Reset translation and rotation of selected IK control(s)' ), pm.menuItem( divider=True ), commandMenuItem( kx.animation.openSwitchParentWindow, label='Switch Parent...' ), pm.menuItem( divider=True ), commandMenuItem( kx.animation.performTransferAnimation ), with pm.subMenuItem( 'Modeling', aob=True, tearOff=True ): # commandMenuItem(kx.modeling.attachObject), commandMenuItem( kx.modeling.performRandomTransform ), # commandMenuItem(kx.modeling.targetCombine), commandMenuItem( kx.modeling.performReplaceShape ), pm.menuItem( divider=True ), commandMenuItem( kx.modeling.matchVertexNormals ), # pm.menuItem(divider=True), # commandMenuItem(kx.modeling.polyFaceProjection), pm.menuItem( divider=True ), commandMenuItem( kx.modeling.reverseOppositeGeometry ), commandMenuItem( kx.modeling.cleanGroupCombine ), with pm.subMenuItem( 'Rigging', aob=True, tearOff=True ): # commandMenuItem(kx.rigging.modifyAttributes), commandMenuItem( kx.rigging.performLockObjects ), commandMenuItem( kx.rigging.performUnlockObjects ), pm.menuItem( divider=True ), commandMenuItem( kx.rigging.performSprintJoint ), pm.menuItem( divider=True ), commandMenuItem( kx.rigging.performTweakJointOrient ) pm.menuItem( divider=True ), commandMenuItem( kx.rigging.resetIkSetup ), commandMenuItem( kx.rigging.switchParentSetup ) pm.menuItem( divider=True ) with pm.subMenuItem( 'Curve Shapes', aob=False, tearOff=True ): commandMenuItem( kx.rigging.createNurbsShape, ( '', 'cube', ), label='Cube' ), commandMenuItem( kx.rigging.createNurbsShape, ( '', 'square', ), label='Square' ), commandMenuItem( kx.rigging.createNurbsShape, ( '', 'sphere', ), label='Sphere' ), commandMenuItem( kx.rigging.createNurbsShape, ( '', 'locator', ), label='Locator' ), commandMenuItem( kx.rigging.createNurbsShape, ( '', 'pointer', ), label='Pointer' ), commandMenuItem( kx.rigging.createNurbsShape, ( '', 'star', ), label='Star' ), commandMenuItem( kx.rigging.createNurbsShape, ( '', 'axis', ), label='Axis' ), commandMenuItem( kx.rigging.createNurbsShape, ( '', 'arrow', ), label='Arrow' ), commandMenuItem( kx.rigging.createNurbsShape, ( '', 'triangle', ), label='Triangle' ), commandMenuItem( kx.rigging.createNurbsShape, ( '', 'circle', ), label='Circle' ), commandMenuItem( kx.rigging.performScaleCurveShape ) with pm.subMenuItem( 'Skinning', aob=True, tearOff=True ): commandMenuItem( kx.skinning.copyVertexWeights ), commandMenuItem( kx.skinning.pasteVertexWeights ), commandMenuItem( kx.skinning.getOverInfluencedVerts ), pm.menuItem( divider=True ), commandMenuItem( kx.skinning.matchSkinning ) with pm.subMenuItem( 'Dynamics', tearOff=True ): commandMenuItem( kx.dynamics.loopDynamics ), commandMenuItem( kx.dynamics.restDynamics ) with pm.subMenuItem( 'Materials', tearOff=True ): commandMenuItem( kx.materials.reloadTextures ) pm.menuItem( divider=True ) with pm.subMenuItem( 'Scene', tearOff=True ) as scene_menu: commandMenuItem( kx.scene.colorWireWindow ), pm.menuItem( divider=True ), commandMenuItem( kx.scene.orderedRename ), commandMenuItem( kx.scene.suffixName ), commandMenuItem( kx.scene.removeNamespaces ), pm.menuItem( divider=True ), commandMenuItem( kx.scene.setRelativeReferences ), pm.menuItem( divider=True ), commandMenuItem( kx.scene.exploreSceneFolder ), pm.menuItem( divider=True ), commandMenuItem( kx.scene.addSelectedToSet ), commandMenuItem( kx.scene.removeSelectedFromSet ), return main_menu
def __init__(self): fg_menu_name = 'fg_menu' if pm.menu(fg_menu_name, query=True, exists=True): pm.deleteUI(fg_menu_name, menu=True) with pm.menu(fg_menu_name, tearOff=True, parent=pm.MelGlobals()['gMainWindow'], label='FG-Tools'): pm.menuItem(dividerLabel='File', divider=True) pm.menuItem(label='Smart Open', image='fileOpen.png', sourceType='mel', command=('int $mods = `getModifiers`;\n' 'if ($mods % 2) { // Shift\n' ' fgReloadScene;\n' '} else {\n' ' fgSmartOpen;\n' '}'), annotation=('Open File and set Project if possible.\n' 'Shift: Reload the current Scene.')) pm.menuItem(label='Save Incremental', sourceType='mel', command='fgSaveIncremental;', annotation='Save a new version of the currently open scene. ' 'The last number in the file will be incremented.') pm.menuItem(label='Save Snapshot', sourceType='mel', command='fgSaveSnapshot;', annotation='Save a snapshot from the viewport in your current render folder.') with pm.subMenuItem(tearOff=True, label='Open Explorer'): pm.menuItem(label='Open Scene Folder', sourceType='mel', command='fgOpenSceneFolder;', annotation='Open the folder where the current scene lives in.') pm.menuItem(label='Open Render Folder', sourceType='mel', command='fgOpenRenderFolder;', annotation='Open the folder that is defined as "images" in the workspace.') pm.menuItem(label='Open Texture Folder', sourceType='mel', command='fgOpenTextureFolder;', annotation='Open the folder that is defined as "Source images" in the workspace.') pm.menuItem(dividerLabel='Select', divider=True) pm.menuItem(label='Select Triangles', command='fgSelectTriangles;', image='fg-icons_triangles_32.png', sourceType='mel', echoCommand=True, annotation='Select triangles from all polygon objects you selected.') pm.menuItem(label='Select N-Gons', image='fg-icons_n-gons_32.png', command='fgSelectNGons;', sourceType='mel', echoCommand=True, annotation='Select n-gons from all polygon objects you selected.') pm.menuItem(label='Select Lamina Faces', image='fg-icons_lamina_32.png', command='fgSelectLaminaFaces;', sourceType='mel', echoCommand=True, annotation='Select lamina faces from all polygon objects you selected.') pm.menuItem(label='Select Non-Manifold Vertices', imageOverlayLabel='NonMani', command='fgSelectNonManifoldVertices;', sourceType='mel', echoCommand=True, annotation='Select non-manifold vertices from all polygon objects you selected.') pm.menuItem(label='Select UV-Seams', imageOverlayLabel='UVSeam', command='fgSelectUVSeams;', sourceType='mel', echoCommand=True, annotation='Select UV-seams from all polygon objects you selected.') pm.menuItem(label='Select Hard Edges', imageOverlayLabel='HardE', command='fgSelectHardEdges;', sourceType='mel', echoCommand=True, annotation='Select hard edges in polygon objects you selected.') pm.menuItem(dividerLabel='Modeling', divider=True) pm.menuItem(label='Spherify', command='fgSpherify;', image='fg_spherify.png', sourceType='mel', echoCommand=True, annotation='Move all selected components to equal distance.') pm.menuItem(label='Move Components to X-Axis', command='fgAverageComponents -axis "x";', image='fg_average_selection_x.png', sourceType='mel', echoCommand=True, annotation='Move all selected components so they are aligned on the x-axis.') pm.menuItem(label='Move Components to Y-Axis', command='fgAverageComponents -axis "y";', image='fg_average_selection_y.png', sourceType='mel', echoCommand=True, annotation='Move all selected components so they are aligned on the y-axis.') pm.menuItem(label='Move Components to Z-Axis', command='fgAverageComponents -axis "z";', image='fg_average_selection_z.png', sourceType='mel', echoCommand=True, annotation='Move all selected components so they are aligned on the z-axis.') pm.menuItem(label='Assign Default Shader', command='fgAssignDefaultShaderToSelection;', image='fg_lambert1.png', sourceType='mel', echoCommand=True, annotation='Assign the Default Shader "lambert1" to all selected objects.') pm.menuItem(label='Toggle X-Ray', command='fgToggleXRayDisplayOfSelection;', image='fg_x_ray.png', sourceType='mel', echoCommand=True, annotation='Toggle X-Ray display in the viewport on all selected objects.') pm.menuItem(dividerLabel='Pivots', divider=True) pm.menuItem(label='Copy Pivot', command='fgCopyPivot;', image='fg_copy_pivot.png', sourceType='mel', echoCommand=True, annotation='Copies the pivot of the selected object.') pm.menuItem(label='Paste Pivot', command='fgPastePivot;', image='fg_paste_pivot.png', sourceType='mel', echoCommand=True, annotation='Pastes the pivot to all selected objects.') pm.menuItem(label='Pivots to WorldCenter', command='fgPivotsToWorldCenter;', image='fg_center_pivot_world.png', sourceType='mel', echoCommand=True, annotation='Moves the pivots of all selected objects to the world-center.') pm.menuItem(label='Pivot to Selection', command='fgPivotToSelection;', imageOverlayLabel='selP', sourceType='mel', echoCommand=True, annotation='Moves the pivot to the middle of the selected components.') pm.menuItem(label='Pivot to Bottom', command='fgPivotToBottom;', imageOverlayLabel='Pbot', sourceType='mel', echoCommand=True, annotation='Moves the pivot to the center of the combined bounding box. Except the y-axis ' 'which will be at the bottom of the bounding box')