当前位置: 首页>>代码示例>>Python>>正文


Python cmds.refresh方法代码示例

本文整理汇总了Python中maya.cmds.refresh方法的典型用法代码示例。如果您正苦于以下问题:Python cmds.refresh方法的具体用法?Python cmds.refresh怎么用?Python cmds.refresh使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在maya.cmds的用法示例。


在下文中一共展示了cmds.refresh方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: suspended_refresh

# 需要导入模块: from maya import cmds [as 别名]
# 或者: from maya.cmds import refresh [as 别名]
def suspended_refresh():
    """Suspend viewport refreshes"""

    try:
        cmds.refresh(suspend=True)
        yield
    finally:
        cmds.refresh(suspend=False) 
开发者ID:getavalon,项目名称:core,代码行数:10,代码来源:lib.py

示例2: run

# 需要导入模块: from maya import cmds [as 别名]
# 或者: from maya.cmds import refresh [as 别名]
def run(self):
        # cmds.waitCursor(status=1)
        cmds.progressBar(self._progress_bar,
                         e=1,
                         bp=1,
                         ii=self._interruptable,
                         status=self._status,
                         min=self._start,
                         max=self._end
                         )
        cmds.refresh() 
开发者ID:wiremas,项目名称:spore,代码行数:13,代码来源:progress_bar.py

示例3: refresh

# 需要导入模块: from maya import cmds [as 别名]
# 或者: from maya.cmds import refresh [as 别名]
def refresh():
        cmds.refresh() 
开发者ID:TomMinor,项目名称:P4VFX,代码行数:4,代码来源:interop.py

示例4: doEditPivotDriver

# 需要导入模块: from maya import cmds [as 别名]
# 或者: from maya.cmds import refresh [as 别名]
def doEditPivotDriver(self, *args):

        newValue = mc.floatSliderButtonGrp(self.floatSlider, query=True, value=True)
        try:
            mc.deleteUI(self.pivotDriverWindow)
        except:
            pass

        currentValue = mc.getAttr(self.pivotDriver)
        if newValue == currentValue:
            return

        oldRP = mc.getAttr(self.node+'.rotatePivot')[0]
        mc.setAttr(self.pivotDriver, newValue)
        newRP = mc.getAttr(self.node+'.rotatePivot')[0]
        mc.setAttr(self.pivotDriver, currentValue)

        parentPosition = mc.group(em=True)
        offsetPosition = mc.group(em=True)
        offsetPosition = mc.parent(offsetPosition, parentPosition)[0]
        mc.setAttr(offsetPosition+'.translate', newRP[0]-oldRP[0], newRP[1]-oldRP[1], newRP[2]-oldRP[2])

        mc.delete(mc.parentConstraint(self.node, parentPosition))

        utl.matchBake(source=[self.node], destination=[parentPosition], bakeOnOnes=True, maintainOffset=False, preserveTangentWeight=False)

        mc.cutKey(self.pivotDriver)
        mc.setAttr(self.pivotDriver, newValue)
        mc.refresh()
        utl.matchBake(source=[offsetPosition], destination=[self.node], bakeOnOnes=True, maintainOffset=False, preserveTangentWeight=False, rotate=False)

        mc.delete(parentPosition) 
开发者ID:morganloomis,项目名称:ml_tools,代码行数:34,代码来源:ml_pivot.py

示例5: drag

# 需要导入模块: from maya import cmds [as 别名]
# 或者: from maya.cmds import refresh [as 别名]
def drag(self, *args):
        '''
        This is what is actually run during the drag, updating the coordinates and calling the
        placeholder drag functions depending on which button is pressed.
        '''

        self.dragPoint = mc.draggerContext(self.draggerContext, query=True, dragPoint=True)

        #if this doesn't work, try getmodifier
        self.modifier = mc.draggerContext(self.draggerContext, query=True, modifier=True)

        self.x = ((self.dragPoint[0] - self.anchorPoint[0]) * self.multiplier) + self.defaultValue
        self.y = ((self.dragPoint[1] - self.anchorPoint[1]) * self.multiplier) + self.defaultValue

        if self.minValue is not None and self.x < self.minValue:
            self.x = self.minValue
        if self.maxValue is not None and self.x > self.maxValue:
            self.x = self.maxValue

        #dragString
        if self.modifier == 'control':
            if self.button == 1:
                self.dragControlLeft(*args)
            elif self.button == 2:
                self.dragControlMiddle(*args)
        elif self.modifier == 'shift':
            if self.button == 1:
                self.dragShiftLeft(*args)
            elif self.button == 2:
                self.dragShiftMiddle(*args)
        else:
            if self.button == 1:
                self.dragLeft()
            elif self.button == 2:
                self.dragMiddle()

        mc.refresh() 
开发者ID:morganloomis,项目名称:ml_tools,代码行数:39,代码来源:ml_utilities.py

示例6: _independent_panel

# 需要导入模块: from maya import cmds [as 别名]
# 或者: from maya.cmds import refresh [as 别名]
def _independent_panel(width, height, off_screen=False):
    """Create capture-window context without decorations

    Arguments:
        width (int): Width of panel
        height (int): Height of panel

    Example:
        >>> with _independent_panel(800, 600):
        ...   cmds.capture()

    """

    # center panel on screen
    screen_width, screen_height = _get_screen_size()
    topLeft = [int((screen_height-height)/2.0),
               int((screen_width-width)/2.0)]

    window = cmds.window(width=width,
                         height=height,
                         topLeftCorner=topLeft,
                         menuBarVisible=False,
                         titleBar=False,
                         visible=not off_screen)
    cmds.paneLayout()
    panel = cmds.modelPanel(menuBarVisible=False,
                            label='CapturePanel')

    # Hide icons under panel menus
    bar_layout = cmds.modelPanel(panel, q=True, barLayout=True)
    cmds.frameLayout(bar_layout, edit=True, collapse=True)

    if not off_screen:
        cmds.showWindow(window)

    # Set the modelEditor of the modelPanel as the active view so it takes
    # the playback focus. Does seem redundant with the `refresh` added in.
    editor = cmds.modelPanel(panel, query=True, modelEditor=True)
    cmds.modelEditor(editor, edit=True, activeView=True)

    # Force a draw refresh of Maya so it keeps focus on the new panel
    # This focus is required to force preview playback in the independent panel
    cmds.refresh(force=True)

    try:
        yield panel
    finally:
        # Delete the panel to fix memory leak (about 5 mb per capture)
        cmds.deleteUI(panel, panel=True)
        cmds.deleteUI(window) 
开发者ID:bumpybox,项目名称:pyblish-bumpybox,代码行数:52,代码来源:capture.py

示例7: reset_pivot

# 需要导入模块: from maya import cmds [as 别名]
# 或者: from maya.cmds import refresh [as 别名]
def reset_pivot(*args):

    sel = mc.ls(sl=True)
    if not sel:
        om.MGlobal.displayWarning('Nothing selected.')
        return

    if len(sel) > 1:
        om.MGlobal.displayWarning('Only works on one node at a time.')
        return

    node = sel[0]
    driver = None
    driver_value = None
    driver_default = None

    if is_pivot_connected(node):
        driver = pivot_driver_attr(node)
        if driver:
            dNode,dAttr = driver.split('.',1)
            driver_value = mc.getAttr(driver)
            driver_default = mc.attributeQuery(dAttr, node=dNode, listDefault=True)[0]
            if driver_default == driver_value:
                return
        else:
            om.MGlobal.displayWarning('Pivot attribute is connected, unable to edit.')
            return

    if not driver:
        pivotPosition = mc.getAttr(node+'.rotatePivot')[0]
        if pivotPosition  == (0.0,0.0,0.0):
            return

    tempPosition = mc.group(em=True)
    tempPivot = mc.group(em=True)
    tempPivot = mc.parent(tempPivot, node)[0]
    if driver:
        mc.setAttr(driver, driver_default)
        newRP = mc.getAttr(node+'.rotatePivot')[0]
        mc.setAttr(driver, driver_value)
        mc.setAttr(tempPivot+'.translate', *newRP)
    else:
        mc.setAttr(tempPivot+'.translate', 0,0,0)

    mc.setAttr(tempPivot+'.rotate', 0,0,0)

    utl.matchBake(source=[tempPivot], destination=[tempPosition], bakeOnOnes=True, maintainOffset=False, preserveTangentWeight=False, rotate=False)

    if driver:
        mc.setAttr(driver, driver_default)
    else:
        mc.setAttr(node+'.rotatePivot', 0,0,0)

    mc.refresh()
    utl.matchBake(source=[tempPosition], destination=[node], bakeOnOnes=True, maintainOffset=False, preserveTangentWeight=False, rotate=False)

    mc.delete(tempPosition,tempPivot)

    mc.select(node) 
开发者ID:morganloomis,项目名称:ml_tools,代码行数:61,代码来源:ml_pivot.py

示例8: createCenterOfMass

# 需要导入模块: from maya import cmds [as 别名]
# 或者: from maya.cmds import refresh [as 别名]
def createCenterOfMass(*args):
    '''
    Create a center of mass node, and constrain it to the
    character based on the selected root node.
    '''

    sel = mc.ls(sl=True)

    if not len(sel) == 1:
        raise RuntimeError('Please select the root control of your puppet.')

    print 'Create Center Of Mass Node'
    print '--------------------------'

    meshes = meshesFromReference(sel[0]) or meshesFromHistory(sel[0])

    if not meshes:
        raise RuntimeError('Could not determine geometry from selected control. Make sure geo is visible.')

    mc.select(meshes)
    mc.refresh()

    print 'Discovered Meshes:'
    for mesh in meshes:
        print '\t',mesh

    skinnedMeshes = []
    for mesh in meshes:
        if utl.getSkinCluster(mesh):
            skinnedMeshes.append(mesh)
            continue
        hist = mc.listHistory(mesh, breadthFirst=True)
        skins = mc.ls(hist, type='skinCluster')
        if not skins:
            warnings.warn('Could not find a skinned mesh affecting {}'.format(mesh))
            continue
        outGeo = mc.listConnections(skins[0]+'.outputGeometry[0]', source=False)
        outGeo = mc.ls(outGeo, type=['mesh','transform'])
        if not outGeo:
            warnings.warn('Could not find a skinned mesh affecting {}'.format(mesh))
            continue
        skinnedMeshes.append(outGeo[0])

    if not skinnedMeshes:
        raise RuntimeError('Could not determine skinned geometry from selected control. This tool will only work if geo is skinned.')

    locator = centerOfMassLocator(skinnedMeshes)

    mc.addAttr(locator, longName=COM_ATTR, attributeType='message')
    mc.connectAttr('.'.join((sel[0],'message')), '.'.join((locator,COM_ATTR)))

    mc.select(sel)
    return locator 
开发者ID:morganloomis,项目名称:ml_tools,代码行数:55,代码来源:ml_centerOfMass.py


注:本文中的maya.cmds.refresh方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。