本文整理汇总了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
示例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),
)
示例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
示例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)
示例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))
示例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('..')
示例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('..')
示例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)
# -------------------------------------------------------------------------
示例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)
# -------------------------------------------------------------------------
示例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()
# -------------------------------------------------------------------------
示例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)
# -------------------------------------------------------------------------
示例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)
示例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)
示例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
示例15: fake_create
# 需要导入模块: from maya import cmds [as 别名]
# 或者: from maya.cmds import setParent [as 别名]
def fake_create(*args, **kwargs):
return cmds.setParent(q=True)