本文整理汇总了Python中maya.cmds.parent方法的典型用法代码示例。如果您正苦于以下问题:Python cmds.parent方法的具体用法?Python cmds.parent怎么用?Python cmds.parent使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类maya.cmds
的用法示例。
在下文中一共展示了cmds.parent方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: info
# 需要导入模块: from maya import cmds [as 别名]
# 或者: from maya.cmds import parent [as 别名]
def info(self, title, description, text, align, width, height, *args):
""" Create a window showing the text info with the description about any module.
"""
# declaring variables:
self.info_title = title
self.info_description = description
self.info_text = text
self.info_winWidth = width
self.info_winHeight = height
self.info_align = align
# creating Info Window:
if cmds.window('dpInfoWindow', query=True, exists=True):
cmds.deleteUI('dpInfoWindow', window=True)
dpInfoWin = cmds.window('dpInfoWindow', title='dpAutoRig - v'+DPAR_VERSION+' - '+self.langDic[self.langName]['i013_info']+' - '+self.langDic[self.langName][self.info_title], iconName='dpInfo', widthHeight=(self.info_winWidth, self.info_winHeight), menuBar=False, sizeable=True, minimizeButton=False, maximizeButton=False)
# creating text layout:
infoColumnLayout = cmds.columnLayout('infoColumnLayout', adjustableColumn=True, columnOffset=['both', 20], parent=dpInfoWin)
cmds.separator(style='none', height=10, parent=infoColumnLayout)
infoLayout = cmds.scrollLayout('infoLayout', parent=infoColumnLayout)
if self.info_description:
infoDesc = cmds.text(self.langDic[self.langName][self.info_description], align=self.info_align, parent=infoLayout)
if self.info_text:
infoText = cmds.text(self.info_text, align=self.info_align, parent=infoLayout)
# call Info Window:
cmds.showWindow(dpInfoWin)
示例2: donateWin
# 需要导入模块: from maya import cmds [as 别名]
# 或者: from maya.cmds import parent [as 别名]
def donateWin(self, *args):
""" Simple window with links to donate in order to support this free and openSource code via PayPal.
"""
# declaring variables:
self.donate_title = 'dpAutoRig - v'+DPAR_VERSION+' - '+self.langDic[self.langName]['i167_donate']
self.donate_description = self.langDic[self.langName]['i168_donateDesc']
self.donate_winWidth = 305
self.donate_winHeight = 300
self.donate_align = "center"
# creating Donate Window:
if cmds.window('dpDonateWindow', query=True, exists=True):
cmds.deleteUI('dpDonateWindow', window=True)
dpDonateWin = cmds.window('dpDonateWindow', title=self.donate_title, iconName='dpInfo', widthHeight=(self.donate_winWidth, self.donate_winHeight), menuBar=False, sizeable=True, minimizeButton=False, maximizeButton=False)
# creating text layout:
donateColumnLayout = cmds.columnLayout('donateColumnLayout', adjustableColumn=True, columnOffset=['both', 20], rowSpacing=5, parent=dpDonateWin)
cmds.separator(style='none', height=10, parent=donateColumnLayout)
infoDesc = cmds.text(self.donate_description, align=self.donate_align, parent=donateColumnLayout)
cmds.separator(style='none', height=10, parent=donateColumnLayout)
brPaypalButton = cmds.button('brlPaypalButton', label=self.langDic[self.langName]['i167_donate']+" - R$ - Real", align=self.donate_align, command=partial(utils.visitWebSite, DONATE+"BRL"), parent=donateColumnLayout)
#usdPaypalButton = cmds.button('usdPaypalButton', label=self.langDic[self.langName]['i167_donate']+" - USD - Dollar", align=self.donate_align, command=partial(utils.visitWebSite, DONATE+"USD"), parent=donateColumnLayout)
# call Donate Window:
cmds.showWindow(dpDonateWin)
示例3: colorizeModuleUI
# 需要导入模块: from maya import cmds [as 别名]
# 或者: from maya.cmds import parent [as 别名]
def colorizeModuleUI(self, colorIndex, *args):
""" Show a little window to choose the color of the button and the override the guide.
"""
# verify integrity of the guideModule:
if self.verifyGuideModuleIntegrity():
# creating colorIndex Window:
if cmds.window('dpColorIndexWindow', query=True, exists=True):
cmds.deleteUI('dpColorIndexWindow', window=True)
colorIndex_winWidth = 160
colorIndex_winHeight = 80
self.dpColorIndexWin = cmds.window('dpColorIndexWindow', title='Color Index', iconName='dpColorIndex', widthHeight=(colorIndex_winWidth, colorIndex_winHeight), menuBar=False, sizeable=False, minimizeButton=False, maximizeButton=False, menuBarVisible=False, titleBar=True)
# creating layout:
colorIndexLayout = cmds.gridLayout('colorIndexLayout', numberOfColumns=8, cellWidthHeight=(20,20))
# creating buttons:
for colorIndex, colorValues in enumerate(self.colorList):
cmds.button('indexColor_'+str(colorIndex)+'_BT', label=str(colorIndex), backgroundColor=(colorValues[0], colorValues[1], colorValues[2]), command=partial(self.setColorModule, colorIndex), parent=colorIndexLayout)
# call colorIndex Window:
cmds.showWindow(self.dpColorIndexWin)
示例4: clearNodeGrp
# 需要导入模块: from maya import cmds [as 别名]
# 或者: from maya.cmds import parent [as 别名]
def clearNodeGrp(nodeGrpName='dpAR_GuideMirror_Grp', attrFind='guideBaseMirror', unparent=False):
""" Check if there is any node with the attribute attrFind in the nodeGrpName and then unparent its children and delete it.
"""
if cmds.objExists(nodeGrpName):
foundChildrenList = []
childrenList = cmds.listRelatives(nodeGrpName, children=True, type="transform")
if childrenList:
for child in childrenList:
if cmds.objExists(child+"."+attrFind) and cmds.getAttr(child+"."+attrFind) == 1:
foundChildrenList.append(child)
if len(foundChildrenList) != 0:
if unparent:
for item in foundChildrenList:
cmds.parent(item, world=True)
cmds.delete(nodeGrpName)
else:
cmds.delete(nodeGrpName)
示例5: zeroOutJoints
# 需要导入模块: from maya import cmds [as 别名]
# 或者: from maya.cmds import parent [as 别名]
def zeroOutJoints(jntList=None):
""" Duplicate the joints, parent as zeroOut.
Returns the father joints (zeroOuted).
Deprecated = using zeroOut function insted.
"""
resultList = []
zeroOutJntSuffix = "_Jzt"
if jntList:
for jnt in jntList:
if cmds.objExists(jnt):
jxtName = jnt.replace("_Jnt", "").replace("_Jxt", "")
if not zeroOutJntSuffix in jxtName:
jxtName += zeroOutJntSuffix
dup = cmds.duplicate(jnt, name=jxtName)[0]
deleteChildren(dup)
clearDpArAttr([dup])
cmds.parent(jnt, dup)
resultList.append(dup)
return resultList
示例6: __createControl
# 需要导入模块: from maya import cmds [as 别名]
# 或者: from maya.cmds import parent [as 别名]
def __createControl(self, cls, shape, clr, i=None, suffix=""):
# create root control
offset, ctrl = control.createControlShape(
"{0}{1}".format(self.name, suffix),
shape,
clr,
i
)
# position control
pos = cluster.getClusterPosition(cls)
cmds.setAttr("{0}.translate".format(offset), *pos)
# parent cluster
cmds.parent(cls, ctrl)
return offset, ctrl
# ------------------------------------------------------------------------
示例7: __init__
# 需要导入模块: from maya import cmds [as 别名]
# 或者: from maya.cmds import parent [as 别名]
def __init__(self, scene, nativeObject):
""" MayaSceneObject's should always have the shape node stored in _nativePointer
MayaSceneObject's should have the transform node stored in _nativeTransform
A transform can have multiple shape nodes, as children, but a shape node can only
have a single transform as its parent. If you init this class with a transform node
it will automaticly convert the native pointer to the first shape node. If you init
this class with a shape node it will use that shape node as the native pointer.
TODO: When we want to add support for swaping shape nodes they should be implemented
as self.setTransform(SceneObject). This will update the _nativeTransform for self and
prevent needing to create a new SceneObject.
"""
# Make sure the nativeObject is a OpenMaya.MObject, and that its a shape node.
mObj = self._asMOBject(nativeObject)
with ExceptionRouter():
nativeObject = self._getShapeNode(mObj)
super(MayaSceneObject, self).__init__(scene, nativeObject)
# store the transform node so we can access it later
self._nativeTransform = self._getTransformNode(mObj)
#--------------------------------------------------------------------------------
# cross3d private methods
#--------------------------------------------------------------------------------
示例8: _nativeChildren
# 需要导入模块: from maya import cmds [as 别名]
# 或者: from maya.cmds import parent [as 别名]
def _nativeChildren(self, recursive=False, wildcard='', type='', parent='', childrenCollector=[]):
"""
\remarks looks up the native children for this object
\param recursive <bool>
\param parent <variant> nativeObject(used for recursive searches when necessary)
\param childrenCollector <list> (used for recursive searches when necessary)
\sa children
\return <list> [ <variant> nativeObject, .. ]
"""
if type:
cross3d.logger.debug('type not implemented yet.')
if parent:
cross3d.logger.debug('parent not implemented yet.')
if childrenCollector:
cross3d.logger.debug('childrenCollector not implemented yet.')
# Convert the wildcard to a regular expression so the generator doesn't have to create the
# regex over and over
regex=None
if wildcard:
expression = application._wildcardToRegex(wildcard)
regex = re.compile(expression, flags=re.I)
return self._mObjChildren(self._nativeTransform, recursive=recursive, regex=regex)
示例9: _nativeModel
# 需要导入模块: from maya import cmds [as 别名]
# 或者: from maya.cmds import parent [as 别名]
def _nativeModel(self):
"""
\remarks looks up the native model for this object
\sa model, setModel, _setNativeModel
\return <variant> nativeObject || None
"""
parent = self.parent()
while parent is not None:
if isinstance(parent, api.SceneModel):
return parent.nativePointer()
parent = parent.parent()
# namespace = self._namespace(self._nativePointer)['namespace']
# if namespace:
# return self._scene._findNativeObject(name=namespace)
return None
示例10: cloneMeshs
# 需要导入模块: from maya import cmds [as 别名]
# 或者: from maya.cmds import parent [as 别名]
def cloneMeshs(meshPaths):
cloneMeshPaths = []
cloneGroup = cmds.group(empty = True, world = True, name = 'ssdsResult')
cloneGroupSL = om.MGlobal.getSelectionListByName(cloneGroup)
cloneGroupFn = om.MFnTransform(cloneGroupSL.getDagPath(0))
for path in meshPaths:
mesh = om.MFnMesh(path)
meshName = om.MFnDagNode(mesh.parent(0)).name()
cloneMeshName = 'ssds:' + meshName
sl = om.MSelectionList();
sl.clear()
sl.add(path)
om.MGlobal.setActiveSelectionList(sl)
cmds.duplicate(returnRootsOnly = True, name = cloneMeshName, renameChildren = True)
cmds.parent(cloneMeshName, cloneGroup)
cmds.setAttr(cloneMeshName + '.inheritsTransform', False)
cloneMeshSL = om.MGlobal.getSelectionListByName(cloneMeshName)
cloneMeshPath = cloneMeshSL.getDagPath(0)
cloneMeshPath.extendToShape()
cloneMeshPaths.append(cloneMeshPath)
return cloneMeshPaths, cloneGroup
示例11: setUp
# 需要导入模块: from maya import cmds [as 别名]
# 或者: from maya.cmds import parent [as 别名]
def setUp(self):
self.group = cmds.createNode("transform", name="skeleton_grp")
cmds.select(cl=True)
j1 = cmds.joint(p=(0, 10, 0))
cmds.joint(p=(1, 9, 0))
cmds.joint(p=(2, 8, 0))
j = cmds.joint(p=(3, 9, 0))
cmds.joint(p=(4, 6, 0))
cmds.joint(p=(5, 5, 0))
cmds.joint(p=(6, 3, 0))
self.cube = cmds.polyCube()[0]
cmds.parent(self.cube, j)
cmds.parent(j1, self.group)
cmds.joint(j1, e=True, oj="xyz", secondaryAxisOrient="yup", ch=True, zso=True)
self.translates = [
cmds.getAttr("{0}.t".format(x))[0] for x in cmds.ls(type="joint")
]
self.rotates = [
cmds.getAttr("{0}.r".format(x))[0] for x in cmds.ls(type="joint")
]
self.orients = [
cmds.getAttr("{0}.jo".format(x))[0] for x in cmds.ls(type="joint")
]
示例12: get_stack
# 需要导入模块: from maya import cmds [as 别名]
# 或者: from maya.cmds import parent [as 别名]
def get_stack(node):
"""Get the transforms in the transform stack
:param node: Stack leaf transform
:return: List of transforms
"""
stack = [node]
parent = cmds.listRelatives(node, parent=True, path=True)
if parent:
parent = parent[0]
while _is_transform_stack_node(parent):
stack.insert(0, parent)
parent = cmds.listRelatives(parent, parent=True, path=True)
if parent:
parent = parent[0]
return stack
示例13: create
# 需要导入模块: from maya import cmds [as 别名]
# 或者: from maya.cmds import parent [as 别名]
def create(
self,
ik_control,
pole_vector=None,
global_scale_attr=None,
pivots=None,
scale_stretch=True,
parent=None,
):
if not cmds.objExists(self.group):
self.group = cmds.createNode("transform", name=self.group)
self.__create_ik(
ik_control, pole_vector, global_scale_attr, pivots, scale_stretch, parent
)
self.__create_fk()
示例14: get_joint_data
# 需要导入模块: from maya import cmds [as 别名]
# 或者: from maya.cmds import parent [as 别名]
def get_joint_data(node):
"""Get the serializable data of a node.
:param node: Joint or transform name.
:return: Data dictionary.
"""
node_type = cmds.nodeType(node)
shapes = cmds.listRelatives(node, children=True, shapes=True)
if node_type not in ["joint", "transform"] or (shapes and node_type == "transform"):
# Skip nodes that are not joints or transforms or if there are shapes below.
return None
parent = cmds.listRelatives(node, parent=True)
parent = parent[0] if parent else None
joint_data = {"nodeType": node_type, "name": node, "parent": parent}
for attr in ATTRIBUTES:
attribute = "{}.{}".format(node, attr)
if not cmds.objExists(attribute):
continue
value = cmds.getAttr(attribute)
if isinstance(value, list):
value = list(value[0])
joint_data[attr] = value
return joint_data
示例15: create
# 需要导入模块: from maya import cmds [as 别名]
# 或者: from maya.cmds import parent [as 别名]
def create(data_list):
"""Create the transform hierarchy.
:param data_list: The list of transform/joint data generated from dumps.
"""
for data in data_list:
node = data["name"]
if not cmds.objExists(node):
node = cmds.createNode(data["nodeType"], name=node)
parent = data["parent"]
if parent and cmds.objExists(parent):
cmds.parent(node, parent)
for attr in ATTRIBUTES:
attribute = "{}.{}".format(node, attr)
if not cmds.objExists(attribute):
continue
value = data[attr]
if isinstance(value, string_types):
cmds.setAttr(attribute, value, type="string")
elif isinstance(value, list):
cmds.setAttr(attribute, *value)
else:
cmds.setAttr(attribute, value)