本文整理汇总了Python中pymel.core.makeIdentity函数的典型用法代码示例。如果您正苦于以下问题:Python makeIdentity函数的具体用法?Python makeIdentity怎么用?Python makeIdentity使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了makeIdentity函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: createPad
def createPad(cls, *args):
if args:
inputObject = args[0]
else:
inputObject = pm.selected()
if type(inputObject) != list:
inputObject = [inputObject]
pads = []
for obj in inputObject:
pm.select(cl = True)
paddingGroup = pm.group(em = True)
upperPaddingGroup = pm.group(em = True)
pm.parent(paddingGroup, upperPaddingGroup)
movePivot = pm.parentConstraint(obj, upperPaddingGroup, mo = False)
pm.delete(movePivot)
pm.parent(obj, paddingGroup)
pm.makeIdentity(apply = True, t = True, r = True, s = True, n = 0)
pm.rename(paddingGroup, obj + '_sdkPad')
pm.rename(upperPaddingGroup, obj + '_offsetPad')
pads.append(upperPaddingGroup)
return pads
示例2: rig_makeCtrlLabel
def rig_makeCtrlLabel(label):
'''Creates a control that is displayed in customized choice of letters
Args:
label (string): the name of the desired control/visual display text
Returns (pm.nt.Transform): returns the display control object
Example Usage:
rig_makeCtrlLabel("display")
'''
if not pm.objExists(label + "_CTRL"):
txt_crv=pm.PyNode( pm.textCurves(ch=0,t=label,f="Courier")[0] )
curves=[]
i=1
for crvShp in pm.ls(txt_crv.getChildren(ad=True), et="nurbsCurve"):
crvTrm = crvShp.getParent()
crvShp.getParent().setParent(w=True)
pm.makeIdentity(crvShp.getParent(),apply=True,s=1,r=1,t=1,n=0)
crvTrm.rename("display_%02d_CRV" % i)
curves.append(crvTrm)
i+=1
displayCtrl=rig_combineCurves(curves,label+'_CTRL')
pm.delete(txt_crv)
displayCtrl.centerPivots()
pm.move(displayCtrl, (0,0,0), rpr=True)
pm.makeIdentity(displayCtrl,apply=True,s=1,r=1,t=1,n=0)
displayGrp=pm.group(em=1,n=(label + "Offset_GRP"))
displayCtrl.setParent(displayGrp)
for displayCtrlShape in displayCtrl.listRelatives(shapes=True, fullPath=True):
pm.setAttr(displayCtrlShape + ".overrideEnabled", 1)
pm.setAttr(displayCtrlShape + ".overrideColor",17)
rig_ctrlLock([displayCtrl], ["tx","ty","tz","rx","ry","rz","sx","sy","sz","v"], setKeyable=False, lock=True)
return displayCtrl
else:
pm.error("That control already exists smarty pants!\n")
示例3: 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']))
示例4: arrows4
def arrows4(name, radius, normal, color):
r = radius
points = [(0.25*r, 0*r, 0.75*r),
(0*r, 0*r, 1*r),
(-.25*r, 0*r, 0.75*r),
(0.25*r, 0*r, 0.75*r),
(0*r, 0*r, 1*r),
(0*r, 0*r, -1*r),
(0.25*r, 0*r, -.75*r),
(-.25*r, 0*r, -.75*r),
(0*r, 0*r, -1*r),
(0*r, 0*r, 0*r),
(-1*r, 0*r, 0*r),
(-.75*r, 0*r, 0.25*r),
(-.75*r, 0*r, -.25*r),
(-1*r, 0*r, 0*r),
(1*r, 0*r, 0*r),
(0.75*r, 0*r, -.25*r),
(0.75*r, 0*r, 0.25*r),
(1*r, 0*r, 0)]
a = pm.curve(point=points, name=name, degree=1, worldSpace=True)
u.aimNormal(a, normal=normal)
pm.makeIdentity(a,apply=True)
a.getShape().overrideEnabled.set(True)
a.getShape().overrideColor.set(color)
return a
示例5: 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
示例6: gimbal
def gimbal(**kwargs):
final = pm.nt.Transform(name = 'Gimbal')
circle1 = pm.modeling.circle(
constructionHistory = False,
normal = kwargs['normal'] if 'normal' in kwargs else [0, 1, 0],
radius = kwargs['radius'] if 'radius' in kwargs else 1
)[0]
circle2 = pm.duplicate(circle1, returnRootsOnly = True)[0]
circle2.rotateBy((90, 0, 0))
circle3 = pm.duplicate(circle1, returnRootsOnly = True)[0]
circle3.rotateBy((0, 0, 90))
for circle in [circle1, circle2, circle3]:
pm.makeIdentity(circle, apply = True)
shape = circle.getShape()
pm.parent(shape, final, shape = True, relative = True)
shape.rename('{0}Circle1Shape'.format(final.nodeName()))
pm.delete(circle)
return final
示例7: build_flexi_jnts
def build_flexi_jnts(self, follicles):
"""
Args:
None
Returns (None)
"""
follicle_prefix = '%s_flexiPlane_' % self.flexiPlaneNameField.getText()
jntGRP_name = self.flexiPlaneNameField.getText() + '_flexiPlane_JNT_GRP'
pm.group( em = True, name = jntGRP_name )
for index,follicle in enumerate(follicles):
jnt_name = self.format_string.format(PREFIX = self.flexiPlaneNameField.getText(),
INDEX = 'flexiPlane_jnt%03d' % (index+1),
SUFFIX = 'JNT')
jnt_offset_name = jnt_name.replace('_JNT','Offset_GRP')
tweek_ctrlCon_name = self.format_string.format(PREFIX = self.flexiPlaneNameField.getText(),
INDEX = 'flexiPlane_tweak%03d' % (index+1),
SUFFIX = 'CTRLCon_GRP')
pm.joint( p = ( follicle.translateX.get(), 0, 0 ), n = jnt_name )
pm.select(jnt_name, r=True)
offSetGRP.add_offset_grps()
pm.parent( jnt_offset_name, jntGRP_name )
pm.select( clear = True )
tweak_ctrl_con = pm.PyNode(tweek_ctrlCon_name)
joint_offset = pm.PyNode(jnt_offset_name)
pm.parentConstraint( tweek_ctrlCon_name, jnt_offset_name )
pm.setAttr(jnt_name + '.rotateZ', -90)
pm.makeIdentity( jnt_name, apply=True, translate=True, rotate=True )
示例8: locatorGrid
def locatorGrid(width, height, depth, offset, centered=True):
'''Create a grid of locators to test upon
Args:
width (int): Width of the grid
height (int): Height of the grid
offset (float): Adds an offset multiplier to the locator positions
centered (bool): determines whether it's centered in world space
Returns (pm.PyNode): The top group of the locator grid
Usage: locatorGrid(5,5,5,2)
'''
if not pm.objExists('locatorGrid'):
grp=pm.group(em=True,n='locatorGrid')
for d in range(0,depth):
for w in range(0,width):
for h in range(0,height):
loc = pm.polyCube(w=.5, h=.5, d=.5, ch=0)[0]
pm.move(loc,(w*offset,h*offset,d*offset), rpr=True)
loc.setParent(grp)
if loc.getShape().type() == "locator":
loc.localScale.set(.2,.2,.2)
if centered:
pm.xform(grp, cp=1)
pm.move(grp, (0, 0, 0), rpr=1)
pm.makeIdentity(grp, apply=True, r=1,s=1,t=1)
return grp
示例9: _create_label
def _create_label(self):
labels = pm.textCurves(ch=0, f="Arial", t=self.label, name="TEMP")
label = pm.duplicate(labels[0])[0]
pm.delete(labels)
label.scale.set([self.label_scale, self.label_scale, self.label_scale])
pm.makeIdentity(label, apply=True, t=True)
shapes = label.listRelatives(ad=True, s=True)
for shape in shapes:
shape.rename("%s_%s" % (self.prefix, shape.name()))
pm.parent(shapes, label, shape=True, relative=True)
label.centerPivots()
label.rename("Text_%s" % self.prefix)
label.overrideEnabled.set(1)
self.control_group.display >> label.overrideDisplayType
self.control_group.display >> label.visibility
pm.delete(label.listRelatives(ad=True, type="transform"))
temp_loc = pm.spaceLocator()
temp_loc.tx.set(self.label_offset[0])
temp_loc.ty.set(self.label_offset[1])
pm.delete(pm.pointConstraint(temp_loc, label, maintainOffset=False))
pm.delete(temp_loc)
pm.parent(label, self.control_group, absolute=True)
示例10: addCurlJnt
def addCurlJnt(side, finger):
# create curl jnt
baseJnt = pm.PyNode(side+finger+'_a_jnt')
loc = pm.PyNode(baseJnt.replace('_a_jnt', 'Cup_loc'))
parJnt = baseJnt.getParent()
# orient loc so x is aimed to baseJnt
if '_rt' in side:
temp_con = pm.aimConstraint(baseJnt, loc, aim=(-1,0,0), u=(0,0,1), wuo=parJnt, wut='objectrotation')
else:
temp_con = pm.aimConstraint(baseJnt, loc, aim=(1,0,0), u=(0,0,1), wuo=parJnt, wut='objectrotation')
pm.delete(temp_con)
# create jnt
pm.select(cl=True)
curlJnt = pm.joint(n=side+finger+'Cup_jnt')
curlJnt.radius.set(baseJnt.radius.get())
mat = loc.getMatrix(ws=True)
curlJnt.setMatrix(mat, ws=True)
parJnt | curlJnt
pm.makeIdentity(curlJnt, r=True, a=True)
# find offset matrix for baseJnt
currMat = baseJnt.getMatrix()
offMat = currMat * curlJnt.getMatrix().inverse()
txOffset = offMat.translate[0]
# change parent for baseJnt
curlJnt | baseJnt
txMd = baseJnt.tx.inputs()[0]
txMd.input2X.set(txOffset)
return curlJnt
示例11: bdMirrorRight
def bdMirrorRight(self):
print "Mirroring left to right"
leftGroup = pm.ls("left:" + self.templateType + "*grp")[0]
rightGroup = pm.ls("right:" + self.templateType + "*grp")[0]
leftGroupPos = leftGroup.getRotatePivot(space="world")
leftGroupPos[0] = -1.0 * leftGroupPos[0]
rightGroup.setTranslation(leftGroupPos, space="world")
leftGrpChildren = leftGroup.listRelatives(f=True, ad=True, type="transform")
rightGrpChildren = rightGroup.listRelatives(f=True, ad=True, type="transform")
i = 0
for target in leftGrpChildren:
targetPos = target.getRotatePivot(space="object")
targetPos = [-2.0 * targetPos[0], 0, 0]
rightGrpChildren[i].translateBy(targetPos, space="object")
pm.makeIdentity(rightGrpChildren[i], apply=True, translate=True, rotate=True, scale=True)
i += 1
i = 0
for target in leftGrpChildren:
mdNode = pm.createNode("multiplyDivide", name=target + "_X_MD")
mdNode.input2X.set(-1)
target.translateX.connect(mdNode.input1X)
mdNode.outputX.connect(rightGrpChildren[i].translateX)
target.translateY.connect(rightGrpChildren[i].translateY)
target.translateZ.connect(rightGrpChildren[i].translateZ)
target.scaleX.connect(rightGrpChildren[i].scaleX)
target.scaleY.connect(rightGrpChildren[i].scaleY)
target.scaleZ.connect(rightGrpChildren[i].scaleZ)
i += 1
示例12: create_background_sphere
def create_background_sphere(name):
'''Create a sphere aligned to aiSkyDomeLight shape'''
xform, _ = pmc.polySphere(radius=995)
shape = xform.getShape()
xform.rename('HDR_Reflector')
# align sphere to aiSkyDomeLight
xform.rotateY.set(71.5)
uv_count = pmc.polyEvaluate(shape, uv=True)
pmc.polyFlipUV(
'{}.map[0:{}]'.format(str(shape), uv_count),
flipType=0,
local=True
)
pmc.delete(xform, ch=True)
pmc.makeIdentity(xform, apply=True)
# set defaults
shape.doubleSided.set(False)
shape.castsShadows.set(False)
shape.receiveShadows.set(False)
shape.opposite.set(True)
shape.aiSelfShadows.set(0)
shape.aiOpaque.set(0)
shape.aiVisibleInDiffuse.set(0)
shape.aiVisibleInGlossy.set(0)
return xform, shape
示例13: makeCube
def makeCube():
squareCrv = dtLib.makeSquare()
squareCrv2 = dtLib.makeSquare()
squareCrv2.setRotation([90, 0,0])
squareCrv2.setTranslation([0,0.5,-0.5])
pm.makeIdentity(apply=True, translate=True, rotate=True, scale=True, normal=1)
crvs = squareCrv2.getShapes()
for current in crvs:
pm.parent(current, squareCrv, relative=True, shape=True)
pm.delete(squareCrv2)
pm.select(squareCrv)
dupCrv = pm.duplicate()
dupCrv[0].setRotation([180, 0, 0])
dupCrv[0].setTranslation([0,0,-1])
pm.makeIdentity(apply=True, translate=True, rotate=True, scale=True, normal=1)
crvs = dupCrv[0].getShapes()
for current in crvs:
pm.parent(current, squareCrv, relative=True, shape=True)
pm.delete(dupCrv)
#中央にピポットを移動
pm.select(squareCrv)
pm.xform(cp=True)
return pm.selected()
示例14: _build
def _build(self, *args):
"""
Builds the joints on the curve.
"""
# naming convention
asset = self.asset
side = self.side
part = self.part
joints = self.joints
suffix = self.suffix
if self.gui:
asset = self.asset_name.text()
side = self.side.currentText()
part = self.part_name.text()
joints = self.joints_box.value()
suffix = self.suffix.currentText()
try:
curve = pm.ls(sl=True)[0]
curve_name = NameUtils.get_unique_name(asset, side, part, "crv")
self.curve = pm.rename(curve, curve_name)
except IndexError:
pm.warning("Please select a curve")
return
length_of_curve = pm.arclen(self.curve)
equal_spacing = length_of_curve / float(joints)
# clear the selection
pm.select(cl=True)
# # create the joints
curve_joints = list()
for x in xrange(int(joints) + 1):
name = NameUtils.get_unique_name(asset, side, part, suffix)
joint = pm.joint(n=name)
curve_joints.append(joint)
joint_position = (x * equal_spacing)
pm.move(0, joint_position, 0)
# rename last joint
last_joint = curve_joints[-1]
pm.rename(last_joint, last_joint + "End")
root_joint = pm.selected()[0].root()
end_joint = pm.ls(sl=True)[0]
solver = 'ikSplineSolver'
# attach joints to curve
ik_name = NameUtils.get_unique_name(asset, side, part, "ikHandle")
self.ikHandle = pm.ikHandle(sj=root_joint, ee=end_joint, sol=solver,
c=self.curve, pcv=True, roc=True, ccv=False, n=ik_name)
joint_chain = pm.ls(root_joint, dag=True)
# delete history
pm.makeIdentity(root_joint, apply=True)
# cleanup
self._cleanup()
示例15: create_curveSphere
def create_curveSphere(name, radius):
circGrp = pm.group(n=name, em=True)
circ1 = pm.circle(nr=[1, 0, 0], ch=True)[0]
circ2 = pm.circle(nr=[1, 0, 0], ch=True)[0]
circ3 = pm.circle(nr=[1, 0, 0], ch=True)[0]
circs = [circ1, circ2, circ3]
circGrp.overrideEnabled.set(1)
circGrp.overrideColorRGB.set(1, 1, 0)
circGrp.overrideRGBColors.set(1)
pm.xform(circGrp, s=[radius, radius, radius])
pm.xform(circ2, ro=[0, 90, 0])
pm.xform(circ3, ro=[0, 0, 90])
pm.makeIdentity([circ1, circ2, circ3], a=True, t=True, r=True, s=True, n=False)
circ1_shape = pm.listRelatives(circ1, s=True)[0]
circ2_shape = pm.listRelatives(circ2, s=True)[0]
circ3_shape = pm.listRelatives(circ3, s=True)[0]
pm.parent([circ1_shape, circ2_shape, circ3_shape], circGrp, r=True, s=True)
pm.delete([circ1, circ2, circ3])
return circGrp