本文整理汇总了Python中pymel.core.parent函数的典型用法代码示例。如果您正苦于以下问题:Python parent函数的具体用法?Python parent怎么用?Python parent使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了parent函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: create
def create(self):
self.handle = pm.group(em=True)
self.result = pm.group(em=True)
self.aim = pm.group(em=True)
self.up = pm.group(em=True)
pm.parent(self.result, self.aim, self.up, self.handle )
# 초기위치 조정
mult = 20
self.aim.t.set(self.aimVec * mult)
self.up.t.set(self.upVec * mult)
self.aimConstraint = pm.aimConstraint(self.aim, self.result, aim=self.aimVec, u=self.upVec, wut='object', wuo=self.up)
# 시각화
self.handle.displayHandle.set(True)
#self.result.displayLocalAxis.set(True)
# 어트리뷰트 잠금
setAttrs( self.result, 'tx','ty','tz','sx','sy','sz','v' )
setAttrs( self.aim, 'rx','ry','rz','sx','sy','sz','v' )
setAttrs( self.up, 'rx','ry','rz','sx','sy','sz','v' )
# 이름변경
self.setPrefix( self.prefix )
示例2: createIkAnimatedJoints
def createIkAnimatedJoints(self):
pm.select(cl = True)
#Iterate jointPositionList and append to ikAnimatedJointsList joint at each position
self.ikAnimatedJointsList = []
for index in range(0, len(self.jointPositionList)):
#create Joint
#decide jointNames
jointName = self.prefix + '_ik_animated_j_' + str(index + 1)
if( index == 0 ): jointName = self.prefix + '_ik_animated_j_' + 'base'
if( index + 1 == len(self.jointPositionList) ): jointName = self.prefix + '_ik_animated_j_' + 'tip'
joint = pm.joint(a = True, p= self.jointPositionList[index] , co = True, n = jointName)
#setJointPreferredAngle for correct ikHandle bending
pm.setAttr(joint.preferredAngleX, -1.0)
self.ikAnimatedJointsList.append(joint)
pm.select(cl = True)
#Create ikAnimatedJointsGrp and parent first ik animated joint
self.ikAnimatedJointsGrp = pm.group(n = self.prefix + '_ik_animated_joints_grp')
pm.select(cl = True)
pm.parent(self.ikAnimatedJointsList[0] , self.ikAnimatedJointsGrp)
pm.select(cl = True)
示例3: createIKSpline
def createIKSpline( jntList ):
pymelLogger.debug('Starting: createIKSpline()...')
# Make IK Spline
ikHandleTorso = pm.ikHandle( startJoint=jntList[0], endEffector=jntList[-1], solver = 'ikSplineSolver', numSpans = 4, name = jntList[-1]+'_'+Names.suffixes['ikhandle'])
# we should probably rename the object created to know names ......
# CAREFULL // inherits Transform OFF, to avoid double transformation when grouped later on
pm.setAttr(ikHandleTorso[2] + '.inheritsTransform', 0)
# Duplicate last and first joint to use as Drivers of the spine Ik curve
print jntList
drvStart = pm.duplicate(jntList[0], parentOnly=True, name = Names.prefixes['driver']+'_'+ jntList[0] +'_'+Names.suffixes['start'])
drvEnd = pm.duplicate(jntList[-1], parentOnly=True, name = Names.prefixes['driver']+'_'+ jntList[-1] +'_'+Names.suffixes['end'])
pm.parent(drvEnd, w=1)
# Make radius bigger
pm.joint(drvStart, edit = True, radius = 1)
pm.joint(drvEnd, edit = True, radius = 1)
# Skin hip/shldr jnt's to back curve
pm.skinCluster(drvStart,drvEnd,ikHandleTorso[2],dr=4)
# return nedded elements
rList = [ikHandleTorso, drvStart, drvEnd ]
pymelLogger.debug('End: createIKSpline()...')
return rList
示例4: buildGuides
def buildGuides(self):
"""
This function setups our guide system
WILL PROBABLY BE ANOTHER CLASS WHEN WE EXPAND AS IT'S GOING TO BE COMPLEX
"""
self.guides = []
for i,p in enumerate(self.posArray):
name = nameUtils.getUniqueName(self.baseNames[i],self.side,"GUIDE")
loc = pm.spaceLocator(n=name)
loc.t.set(p)
loc.r.set(self.rotArray[i])
self.guides.append(loc)
tempGuides = list(self.guides)
tempGuides.reverse()
for i in range(len(tempGuides)):
if i != (len(tempGuides)-1):
pm.parent(tempGuides[i],tempGuides[i+1])
name = nameUtils.getUniqueName(self.baseName+"_guides",self.side,"grp")
self.guidesGrp = pm.createNode("transform",n=name)
self.guides[0].setParent(self.guidesGrp)
示例5: __generateMesh
def __generateMesh( self, mesh, positions, radius, iteration ):
instanceGroup = pm.group( empty = True, name = "meshInstanceGroup" )
positionsLength = len( positions )
instances = [ None ] * positionsLength
for i in range(0, positionsLength):
position = scaleVector( positions[ i ], radius )
if i == 0:
meshInstance = mesh
meshInstance[ 0 ].setTranslation( position )
else:
meshInstance = pm.instance( mesh[ 0 ] )
meshInstance[ 0 ].setTranslation(position)
instances[ i ] = meshInstance[ 0 ]
pm.parent( instances, instanceGroup, add = True )
return combineClean( instanceGroup, "Sierpinski_Iteration_%i" % iteration )
示例6: AlignBindNode
def AlignBindNode(self, **kws):
'''
Overwrite the default behaviour: Align the newly made BindNode as required for this bind
'''
parentNode = self.SourceNode.listRelatives(p=True)[0]
if parentNode:
#Parent the BindNode to the Source Driver Node
pm.parent(self.BindNode['Root'], self.SourceNode.listRelatives(p=True)[0])
else:
pm.parent(self.BindNode['Root'], self.SourceNode)
self.BindNode['Main'].rotateOrder.set(self.SourceNode.rotateOrder.get())
self.BindNode['Root'].rotateOrder.set(self.DestinationNode.rotateOrder.get())
#Positional Alignment
if self.Settings.AlignToControlTrans:
pm.delete(pm.pointConstraint(self.SourceNode, self.BindNode['Root']))
pm.makeIdentity(self.BindNode['Root'], apply=True, t=1, r=0, s=0)
pm.delete(pm.pointConstraint(self.DestinationNode, self.BindNode['Root']))
if self.Settings.AlignToSourceTrans:
pm.delete(pm.pointConstraint(self.SourceNode, self.BindNode['Root']))
pm.makeIdentity(self.BindNode['Root'], apply=True, t=1, r=0, s=0)
#Rotation Alignment
if parentNode:
pm.orientConstraint(self.SourceNode, self.BindNode['Root'])
if self.Settings.AlignToControlRots:
pm.delete(pm.orientConstraint(self.DestinationNode, self.BindNode['Main']))
if self.Settings.AlignToSourceRots:
pm.delete(pm.orientConstraint(self.SourceNode, self.BindNode['Main']))
示例7: __transformToBone__
def __transformToBone__(obj):
name = obj.name()
# create joint
jnt = pmc.createNode('joint', name=name+'_')
# set parent
if obj.getParent():
jnt.setParent(obj.getParent())
# set transformation
jnt.setTranslation(obj.getTranslation(space='object'), space='object')
jnt.setRotationOrder(obj.getRotationOrder(), reorder=True)
jnt.jointOrientX.set(obj.getRotation(space='object')[0])
jnt.jointOrientY.set(obj.getRotation(space='object')[1])
jnt.jointOrientZ.set(obj.getRotation(space='object')[2])
jnt.setScale(obj.getScale())
jnt.setShear(obj.getShear())
# get children
children = obj.getChildren()
for child in children:
child = various.checkObj(child, type=['transform', 'joint'], echo=False)
if child:
child.setParent(jnt)
# parent shape
if obj.getShape():
pmc.parent(obj.getShape(), jnt, shape=True, relative=True)
# deleting and renaming properly
pmc.delete(obj)
jnt.rename(name)
return jnt
示例8: makeLoc
def makeLoc(obj=None):
# Place locator as child to jnt and zero it
loc = pm.spaceLocator()
pm.parent(loc, obj)
loc.setTranslation(0)
loc.setRotation([0, 0, 0])
return loc
示例9: ExtraControlForJnt
def ExtraControlForJnt( jnts=None ) :
if not jnts:
jnts = pm.ls( sl=True )
else:
jnts = pm.ls( jnts )
for jnt in jnts:
# duplicate joint
pm.select( clear=True )
newJnt = pm.joint( p = [0,0,0], name= '%s_extra'%jnt.name() )
pm.delete( pm.pointConstraint( jnt, newJnt ) )
pm.delete( pm.orientConstraint( jnt, newJnt ) )
pm.parent( newJnt, jnt )
newJnt.jointOrient.set( jnt.jointOrient.get() )
# create control curve for joint
ctrl = CubeCrv( name = '%s_ctrl'%jnt.name() )
pm.delete( pm.pointConstraint( jnt, ctrl ) )
pm.delete( pm.orientConstraint( jnt, ctrl ) )
zeroAndOfs = ZeroGrp( ctrl )
ctrl.translate >> newJnt.translate
ctrl.rotate >> newJnt.rotate
ctrl.scale >> newJnt.scale
# make controls to move with base joints
pm.parentConstraint( jnt, zeroAndOfs[0] )
pm.scaleConstraint( jnt, zeroAndOfs[0] )
示例10: jointsOnCurve
def jointsOnCurve(crv=None, num=None, name=None):
if not crv: return
if not num: return
if not name: return
if num < 1: return
param_increment = 1.0/float(num)
param = 0
curveShape = pm.PyNode(crv).getShape()
prnt = []
for i in range(num):
pm.select(clear=1)
# Create joint
jnt = pm.joint(n=name+'_'+str(i).zfill(2))
# Attach to curve
poci = pm.createNode('pointOnCurveInfo')
pm.connectAttr('%s.ws'%curveShape,'%s.inputCurve'%poci,f=1)
pm.connectAttr('%s.position'%poci,'%s.translate'%jnt,f=1)
pm.setAttr('%s.parameter'%poci,param)
pm.setAttr('%s.turnOnPercentage'%poci,1)
pm.disconnectAttr('%s.position'%poci,'%s.translate'%jnt)
pm.delete(poci)
if len(prnt):
pm.parent(jnt,prnt[-1])
prnt.append(jnt)
param += param_increment
示例11: addZero
def addZero(*args, **kwargs):
oblist = makeList(args)
results = []
for item in oblist:
if item.type() == 'joint':
zero = pm.createNode('transform', n=item+'Zero')
zero.rotateOrder.set( item.rotateOrder.get() )
snap(zero, item)
pm.parent(item, zero)
results.append(zero)
elif item.type() == 'transform':
zero = pm.duplicate(item, rr=True)[0]
children = zero.getChildren()
if len(children):
pm.delete(children)
zero.rename(item+'Zero')
for attr in 'trs':
for axis in 'xyz':
pAttr = zero.attr(attr+axis)
pAttr.set(lock=False)
pAttr.set(k=True)
pm.parent(item, zero)
results.append(zero)
if len(results) == 0:
return None
elif len(results) == 1:
return(results[0])
else:
return(results)
示例12: FTM_createRulerPlane
def FTM_createRulerPlane( control, axisPlane, isMainDirX, transformParent, dummyRulerTransform ):
obj = pm.polyPlane( axis=axisPlane, ch=True, w=1, h=1, sx=1, sy=1 )
if isMainDirX == True:
bDir = 'width'
bSubDir = 'subdivisionsWidth'
sDir = 'height'
sSubDir = 'subdivisionsHeight'
else:
sDir = 'width'
sSubDir = 'subdivisionsWidth'
bDir = 'height'
bSubDir = 'subdivisionsHeight'
pm.connectAttr( control+'.controlSize2', obj[1]+'.'+bDir)
pm.connectAttr( control+'.rulerDivisions2', obj[1]+'.'+bSubDir)
pm.connectAttr( control+'.rulerSmallSize', obj[1]+'.'+sDir)
shapeTransformDriver = dummyRulerTransform
if shapeTransformDriver is None:
shapeTransformDriver = obj[0]
outShp = FTM_createTransformedGeometry(obj[0], 'outMesh', 'inMesh', shapeTransformDriver )
#shps = pm.listRelatives(obj[0],s=True)
pm.connectAttr( control+'.rulerDisplay', outShp+'.visibility')
pm.setAttr(outShp+'.template', 1)
if transformParent is None:
pm.parent(obj[0], control)
return obj[0]
else:
pm.parent(outShp,transformParent, add=True, s=True)
pm.delete( obj[0] )
示例13: rigBook
def rigBook(containers):
center = createJointChain(name='center')
left = createJointChain(name='left')
right = createJointChain(name='right')
ctrl = containers["ctrl"]
pm.addAttr(containers["ctrl"],
ln="_",
at="enum",
en="______"
)
pm.setAttr(containers["ctrl"]+"._", e=1, keyable=1)
for page in range(pages):
pageName = 'page'+str(page)
skin = createJointChain(pageName+"_")
rigPage(skin, center, left, right, ctrl, pageName)
paper = createPaper(pageName)
pm.select(skin, r=1, hi=1)
pm.select(paper, add=1, )
pm.bindSkin(toAll = 1, colorJoints = 1)
pm.select(cl=1)
pm.parent(paper, containers["paper_grp"])
pm.parent(skin[0], containers["pages_grp"])
pm.select(cl=1)
print "rigged: %s" % pageName
pm.parent(center[0], containers["pageTargets_grp"])
pm.parent(left[0], containers["pageTargets_grp"])
pm.parent(right[0], containers["pageTargets_grp"])
示例14: createBoundJointChain
def createBoundJointChain(self):
pm.select(cl = True)
#Iterate highResCurveCoordList and append to boundJointsList joint at each position
self.boundJointsList = []
for index in range(0, len(self.highResCurveCoordList)):
#create Joint
#decide jointNames
jointName = self.prefix + '_bound_j_' + str(index + 1)
if( index == 0 ): jointName = self.prefix + '_bound_j_' + 'base'
if( index + 1 == len(self.highResCurveCoordList) ): jointName = self.prefix + '_bound_j_' + 'tip'
joint = pm.joint(a = True, p= self.highResCurveCoordList[index] , co = True, n = jointName)
self.boundJointsList.append(joint)
pm.select(cl = True)
#Orient boundJoints
pm.joint(self.boundJointsList[0], e = True, sao = 'yup', oj='xyz', zso = True, ch = True)
pm.select(cl = True)
#Create boundJointsGrp and parent first bound joint
self.boundJointsGrp = pm.group(n = self.prefix + '_bound_joints_grp')
pm.select(cl = True)
pm.parent(self.boundJointsList[0] , self.boundJointsGrp)
pm.select(cl = True)
示例15: transfer_shape
def transfer_shape(source, target, snap_to_target=True, fix_name=False):
"""
Reparent a shape node from one parent to another
@param source: The source dag which contains the shape
@param target: The source dag which will have the new shape the shape
@param snap_to_target: Should be we reparent with world space or object space
@param fix_name: Should we match the name of the shape to the new target
@return:
"""
source = force_pynode(source)
target = force_pynode(target)
if snap_to_target:
snap(source, target)
pm.makeIdentity(source, apply=1)
if source.getShape().type() != "locator":
try:
pm.cluster(source)
pm.delete(source, ch=1)
except RuntimeError:
logger.warning("Cannot cluster {}".format(source))
oldShape = source.getShape()
pm.parent(oldShape, target, shape=1, relative=1)
if fix_name:
fix_shape_name(target)
return oldShape