當前位置: 首頁>>代碼示例>>Python>>正文


Python cmds.setParent方法代碼示例

本文整理匯總了Python中maya.cmds.setParent方法的典型用法代碼示例。如果您正苦於以下問題:Python cmds.setParent方法的具體用法?Python cmds.setParent怎麽用?Python cmds.setParent使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在maya.cmds的用法示例。


在下文中一共展示了cmds.setParent方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: initializeMenu

# 需要導入模塊: from maya import cmds [as 別名]
# 或者: from maya.cmds import setParent [as 別名]
def initializeMenu(self, entries):
        try:
            # gMainWindow = MayaInterop.main_parent_window()
            gMainWindow = maya.mel.eval('$temp1=$gMainWindow')
        except RuntimeError as e:
            print e
            print 'Are you running in Batch Python?'
            gMainWindow = None

        try:
            print 'Initialising menu...'
            self.perforceMenu = cmds.menu("PerforceMenu", parent=gMainWindow, tearOff=True, label='Perforce')
            cmds.setParent(self.perforceMenu, menu=True)
        except RuntimeError as e:
            print 'Maya error while trying to create menu:',
            print e 
開發者ID:TomMinor,項目名稱:P4VFX,代碼行數:18,代碼來源:interop.py

示例2: __init__

# 需要導入模塊: from maya import cmds [as 別名]
# 或者: from maya.cmds import setParent [as 別名]
def __init__(self, title, help_url=None):
        layout = mel.eval("getOptionBox")
        cmds.setParent(layout)
        mel.eval('setOptionBoxTitle("{}");'.format(title))
        self.create_ui()

        apply_close_button = mel.eval("getOptionBoxApplyAndCloseBtn;")
        cmds.button(apply_close_button, e=True, command=self._apply_and_close)
        apply_button = mel.eval("getOptionBoxApplyBtn;")
        cmds.button(apply_button, e=True, command=self._on_apply)
        close_button = mel.eval("getOptionBoxCloseBtn;")
        cmds.button(close_button, e=True, command=self._close)

        if help_url:
            help_item = mel.eval("getOptionBoxHelpItem;")
            cmds.menuItem(
                help_item,
                e=True,
                label="Help on {}".format(title),
                command='import webbrowser; webbrowser.open("{}")'.format(help_url),
            ) 
開發者ID:chadmv,項目名稱:cmt,代碼行數:23,代碼來源:optionbox.py

示例3: colorControlLayout

# 需要導入模塊: from maya import cmds [as 別名]
# 或者: from maya.cmds import setParent [as 別名]
def colorControlLayout(self, label=''):
        mc.rowLayout( numberOfColumns=4,
                      columnWidth4=(150, 200, 90, 80),
                      adjustableColumn=2,
                      columnAlign=(1, 'right'),
                      columnAttach=[(1, 'both', 0),
                                    (2, 'both', 0),
                                    (3, 'both', 0),
                                    (4, 'both', 0)] )
        mc.text(label=label)
        colorSlider = mc.colorSliderGrp( label='', adj=2, columnWidth=((1,1),(3,1)))
        mc.button(label='From Selected',
                  ann='Get the color of the selected object.',
                  command=partial(self.setFromSelected, colorSlider))
        mc.button(label='Randomize',
                  ann='Set a random color.',
                  command=partial(self.randomizeColors, colorSlider))
        controls = mc.layout(colorSlider, query=True, childArray=True)

        mc.setParent('..')

        return colorSlider 
開發者ID:morganloomis,項目名稱:ml_tools,代碼行數:24,代碼來源:ml_colorControl.py

示例4: quickBreakDownUI

# 需要導入模塊: from maya import cmds [as 別名]
# 或者: from maya.cmds import setParent [as 別名]
def quickBreakDownUI():
    winName = 'ml_quickBreakdownWin'
    if mc.window(winName, exists=True):
        mc.deleteUI(winName)

    mc.window(winName, title='ml :: QBD', iconName='Quick Breakdown', width=100, height=500)

    mc.columnLayout(adj=True)

    mc.paneLayout(configuration='vertical2', separatorThickness=1)
    mc.text('<<')
    mc.text('>>')
    mc.setParent('..')

    for v in (10,20,50,80,90,100,110,120,150):
        mc.paneLayout(configuration='vertical2',separatorThickness=1)

        mc.button(label=str(v)+' %', command=partial(weightPrevious,v/100.0))
        mc.button(label=str(v)+' %', command=partial(weightNext,v/100.0))
        mc.setParent('..')

    mc.showWindow(winName)

    mc.window(winName, edit=True, width=100, height=250) 
開發者ID:morganloomis,項目名稱:ml_tools,代碼行數:26,代碼來源:ml_breakdown.py

示例5: attributeMenuItem

# 需要導入模塊: from maya import cmds [as 別名]
# 或者: from maya.cmds import setParent [as 別名]
def attributeMenuItem(node, attr):

    plug = node+'.'+attr
    niceName = mc.attributeName(plug, nice=True)

    #get attribute type
    attrType = mc.getAttr(plug, type=True)

    if attrType == 'enum':
        listEnum = mc.attributeQuery(attr, node=node, listEnum=True)[0]
        if not ':' in listEnum:
            return
        listEnum = listEnum.split(':')
        mc.menuItem(label=niceName, subMenu=True)
        for value, label in enumerate(listEnum):
            mc.menuItem(label=label, command=partial(mc.setAttr, plug, value))
        mc.setParent('..', menu=True)
    elif attrType == 'bool':
        value = mc.getAttr(plug)
        label = 'Toggle '+ niceName
        mc.menuItem(label=label, command=partial(mc.setAttr, plug, not value)) 
開發者ID:morganloomis,項目名稱:ml_tools,代碼行數:23,代碼來源:ml_puppet.py

示例6: buildMainLayout

# 需要導入模塊: from maya import cmds [as 別名]
# 或者: from maya.cmds import setParent [as 別名]
def buildMainLayout(self):
        '''Build the main part of the ui
        '''
        #self.cbBakeOnes = mc.checkBoxGrp(label='Bake on Ones',
                                         #annotation='Bake every frame. If deselected, the tool will preserve keytimes.')

        #mc.separator()
        self.ButtonWithPopup(label='Create Live COM',
                             command=createCenterOfMass,
                             annotation='Create a constrained COM node based on selected Root Control.')

        mc.paneLayout(configuration='vertical2',separatorThickness=1)
        self.ButtonWithPopup(label='Transfer Root Anim to COM',
                             command=bakeCenterOfMass,
                             annotation='Bake out the Root animation to the COM node.')
        self.ButtonWithPopup(label='Transfer COM back to Root',
                             command=bakeRoot,
                             annotation='A previously baked COM will be baked back to its corresponding Root.')
        mc.setParent('..') 
開發者ID:morganloomis,項目名稱:ml_tools,代碼行數:21,代碼來源:ml_centerOfMass.py

示例7: add_brush_btn

# 需要導入模塊: from maya import cmds [as 別名]
# 或者: from maya.cmds import setParent [as 別名]
def add_brush_btn(self, attr):
        """ replace the default combobox with a button for each entry """

        cmds.rowLayout('instanceLayout', nc=8 ) #, adjustableColumn=6) #, w=270 ) #, columnWidth3=(80, 75, 150),  columnAlign=(1, 'right'), columnAttach=[(1, 'both', 0), (2, 'both', 0), (3, 'both', 0)] )
        cmds.text(l='Tool', align='right', w=145)
        cmds.button('placeBtn', l='Place', c=pm.Callback(self.activateContext, 'place', attr, 0))
        cmds.button('sprayBtn', l='Spray', c=pm.Callback(self.activateContext, 'spray', attr, 1))
        cmds.button('scaleBtn', l='Scale', c=pm.Callback(self.activateContext, 'scale', attr, 2))
        cmds.button('alignBtn', l='Align', c=pm.Callback(self.activateContext, 'align', attr, 3))
        cmds.button('moveBtn', l='Move', c=pm.Callback(self.activateContext, 'move', attr, 4))
        cmds.button('idBtn', l='Id', c=pm.Callback(self.activateContext, 'id', attr, 5))
        cmds.button('removeBtn', l='Remove', c=pm.Callback(self.activateContext, 'remove', attr, 6))
        cmds.setParent('..') 
開發者ID:wiremas,項目名稱:spore,代碼行數:15,代碼來源:AEsporeNodeTemplate.py

示例8: get

# 需要導入模塊: from maya import cmds [as 別名]
# 或者: from maya.cmds import setParent [as 別名]
def get(cls, name, layout=None):
        
        if not layout:
            layout = cls.top_level_layout()

        cmds.setParent(layout)
        shelf = cmds.shelfLayout(name, q=True, exists=True)

        if shelf:
            return cls(name, layout)
        else:
            raise NameError("Unable to find shelf: " + name)

    # ------------------------------------------------------------------------- 
開發者ID:Clemson-DPA,項目名稱:dpa-pipe,代碼行數:16,代碼來源:shelf.py

示例9: add_button

# 需要導入模塊: from maya import cmds [as 別名]
# 或者: from maya.cmds import setParent [as 別名]
def add_button(self, **kwargs):

        import sys

        # intercept/adjust some of the arguments
        for (key, val) in kwargs.iteritems():

            # get full image path
            if key.startswith("image") and IconFactory.is_icon_path(val):
                kwargs[key] = self.icon_factory.disk_path(val)

        cmds.setParent("|".join([self.layout, self.name]))
        cmds.shelfButton(**kwargs)

    # ------------------------------------------------------------------------- 
開發者ID:Clemson-DPA,項目名稱:dpa-pipe,代碼行數:17,代碼來源:shelf.py

示例10: create

# 需要導入模塊: from maya import cmds [as 別名]
# 或者: from maya.cmds import setParent [as 別名]
def create(self):
        cmds.setParent(self.layout)
        cmds.shelfLayout(self.name)
        self._shelf_error_fix()

    # ------------------------------------------------------------------------- 
開發者ID:Clemson-DPA,項目名稱:dpa-pipe,代碼行數:8,代碼來源:shelf.py

示例11: exists

# 需要導入模塊: from maya import cmds [as 別名]
# 或者: from maya.cmds import setParent [as 別名]
def exists(self):
        cmds.setParent(self.layout)
        return cmds.shelfLayout(self.name, q=True, exists=True)

    # ------------------------------------------------------------------------- 
開發者ID:Clemson-DPA,項目名稱:dpa-pipe,代碼行數:7,代碼來源:shelf.py

示例12: install

# 需要導入模塊: from maya import cmds [as 別名]
# 或者: from maya.cmds import setParent [as 別名]
def install():
    """ Installs dag menu option
    """

    # get state
    state = get_option_var_state()

    cmds.setParent(mgear.menu_id, menu=True)
    cmds.menuItem("mgear_dagmenu_menuitem", label="mGear Viewport Menu ",
                  command=run, checkBox=state)
    cmds.menuItem(divider=True)

    run(state) 
開發者ID:mgear-dev,項目名稱:mgear_core,代碼行數:15,代碼來源:dagmenu.py

示例13: __init__

# 需要導入模塊: from maya import cmds [as 別名]
# 或者: from maya.cmds import setParent [as 別名]
def __init__(self, parent=None, *args, **kwargs):
        super(BaseDialog, self).__init__(parent, *args, **kwargs)
        template = 'dialogWindow{}'
        for i in count(1):
            name = template.format(i)
            if not cmds.window(name, exists=True):
                self.setObjectName(name)
                break
        cmds.setParent(self) 
開發者ID:theodox,項目名稱:mGui,代碼行數:11,代碼來源:QDialog.py

示例14: __init__

# 需要導入模塊: from maya import cmds [as 別名]
# 或者: from maya.cmds import setParent [as 別名]
def __init__(self, parent=None, *args, **kwargs):
        super(QWidgetBaseMixin, self).__init__(parent, *args, **kwargs)
        try:
            cmds.setParent(self)
        except RuntimeError:
            pass 
開發者ID:theodox,項目名稱:mGui,代碼行數:8,代碼來源:_mixins.py

示例15: fake_create

# 需要導入模塊: from maya import cmds [as 別名]
# 或者: from maya.cmds import setParent [as 別名]
def fake_create(*args, **kwargs):
        return cmds.setParent(q=True) 
開發者ID:theodox,項目名稱:mGui,代碼行數:4,代碼來源:forms.py


注:本文中的maya.cmds.setParent方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。