Python maya.cmds.setFocus() Examples

The following are 6 code examples of maya.cmds.setFocus(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module maya.cmds , or try the search function .
Example #1
Source File: synoptic.py    From SiShelf with MIT License 6 votes vote down vote up
def node_select(selectpartslist):
    newselectpartslist = []
    for i in selectpartslist:
        if cmds.objExists(i):
            newselectpartslist.append(i)
        else:
            print 'No Object "'+i+'" !!!'
    modi = cmds.getModifiers()
    if modi == 0:
        cmds.select(newselectpartslist, r=True)
    elif modi == 1:
        cmds.select(newselectpartslist, tgl=True)
    elif modi == 5:
        cmds.select(newselectpartslist, add=True)
    elif modi == 4:
        cmds.select(newselectpartslist, d=True)
    #cmds.setFocus("MayaWindow") 
Example #2
Source File: ml_utilities.py    From ml_tools with MIT License 6 votes vote down vote up
def getModelPanel():
    '''Return the active or first visible model panel.'''
    
    panel = mc.getPanel(withFocus=True)

    if mc.getPanel(typeOf=panel) != 'modelPanel':
        #just get the first visible model panel we find, hopefully the correct one.
        panels = getModelPanels()
        if panels:
            panel = panels[0]
            mc.setFocus(panel)
    
    if mc.getPanel(typeOf=panel) != 'modelPanel':
        OpenMaya.MGlobal.displayWarning('Please highlight a camera viewport.')
        return None
    return panel 
Example #3
Source File: tests.py    From maya-capture with MIT License 5 votes vote down vote up
def test_parse_active_view():
    """Parse active view works"""

    # Set focus to modelPanel1 (assume it exists)
    # Otherwise the panel with focus (temporary panel from capture)
    # got deleted and there's no "active panel"
    import maya.cmds as cmds
    cmds.setFocus("modelPanel1")

    options = capture.parse_active_view()
    capture.capture(**options) 
Example #4
Source File: boundCollection.py    From mGui with MIT License 5 votes vote down vote up
def update_filter(self, *args, **kwargs):
        sender = kwargs['sender']
        def filter_exp(x):
            return sender.text in x
        if sender.text:
            self.collection.update_filter(filter_exp)
        else:
            self.collection.update_filter(None)
        cmds.setFocus(self.window.main.flt.filter_text) 
Example #5
Source File: ml_utilities.py    From ml_tools with MIT License 5 votes vote down vote up
def getCurrentCamera():
    '''
    Returns the camera that you're currently looking through.
    If the current highlighted panel isn't a modelPanel,
    '''

    panel = mc.getPanel(withFocus=True)

    if mc.getPanel(typeOf=panel) != 'modelPanel':
        #just get the first visible model panel we find, hopefully the correct one.
        for p in mc.getPanel(visiblePanels=True):
            if mc.getPanel(typeOf=p) == 'modelPanel':
                panel = p
                mc.setFocus(panel)
                break

    if mc.getPanel(typeOf=panel) != 'modelPanel':
        OpenMaya.MGlobal.displayWarning('Please highlight a camera viewport.')
        return False

    camShape = mc.modelEditor(panel, query=True, camera=True)
    if not camShape:
        return False

    camNodeType = mc.nodeType(camShape)
    if mc.nodeType(camShape) == 'transform':
        return camShape
    elif mc.nodeType(camShape) in ['camera','stereoRigCamera']:
        return mc.listRelatives(camShape, parent=True, path=True)[0] 
Example #6
Source File: canvas.py    From spore with MIT License 4 votes vote down vote up
def enter_widget(self):
        """ set focuts to the panel under the cursor """

        panel = cmds.getPanel(underPointer=True)
        cmds.setFocus(panel)
        self.setFocus()