本文整理匯總了Python中pymel.core.rename方法的典型用法代碼示例。如果您正苦於以下問題:Python core.rename方法的具體用法?Python core.rename怎麽用?Python core.rename使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類pymel.core
的用法示例。
在下文中一共展示了core.rename方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: addLocator
# 需要導入模塊: from pymel import core [as 別名]
# 或者: from pymel.core import rename [as 別名]
def addLocator(parent, name, m=datatypes.Matrix(), size=1):
"""Create a space locator dagNode.
Arguments:
parent (dagNode): The parent for the node.
name (str): The Node name.
m (matrix): The matrix for the node transformation (optional).
size (float): The space locator shape size (optional).
Returns:
dagNode: The newly created node.
"""
node = pm.PyNode(pm.createNode("locator")).getParent()
node.rename(name)
node.setTransformation(m)
node.setAttr("localScale", size, size, size)
if parent is not None:
parent.addChild(node)
return node
示例2: addLocatorFromPos
# 需要導入模塊: from pymel import core [as 別名]
# 或者: from pymel.core import rename [as 別名]
def addLocatorFromPos(parent, name, pos=datatypes.Vector(0, 0, 0), size=1):
"""Create a space locator dagNode.
Arguments:
parent (dagNode): The parent for the node.
name (str): The Node name.
pos (vector): The vector for the node position (optional).
size (float): The space locator shape size (optional).
Returns:
dagNode: The newly created node.
"""
node = pm.PyNode(pm.createNode("locator")).getParent()
node.rename(name)
node.setTranslation(pos, space="world")
node.setAttr("localScale", size, size, size)
if parent is not None:
parent.addChild(node)
return node
# ===========================================
# JOINT
示例3: get_pin_shader
# 需要導入模塊: from pymel import core [as 別名]
# 或者: from pymel.core import rename [as 別名]
def get_pin_shader(self):
"""this creates or returns the existing pin shader
"""
shaders = pm.ls("%s*" % self.pin_shader_prefix)
if shaders:
# try to find the shader with the same color
for shader in shaders:
if list(shader.color.get()) == self.color:
return shader
# so we couldn't find a shader
# lets create one
shader = pm.shadingNode("lambert", asShader=1)
shader.rename("%s#" % self.pin_shader_prefix)
shader.color.set(self.color)
# also create the related shadingEngine
shading_engine = pm.nt.ShadingEngine()
shading_engine.rename("%sSG#" % self.pin_shader_prefix)
shader.outColor >> shading_engine.surfaceShader
return shader
示例4: duplicate
# 需要導入模塊: from pymel import core [as 別名]
# 或者: from pymel.core import rename [as 別名]
def duplicate(self, class_=None, prefix="", suffix=""):
"""duplicates itself and returns a new joint hierarchy
:param class_: The class of the created JointHierarchy. Default value
is JointHierarchy
:param prefix: Prefix for newly created joints
:param suffix: Suffix for newly created joints
"""
if class_ is None:
class_ = self.__class__
new_start_joint = pm.duplicate(self.start_joint)[0]
all_hierarchy = list(reversed(new_start_joint.listRelatives(ad=1, type=pm.nt.Joint)))
new_end_joint = all_hierarchy[len(self.joints) - 2]
# delete anything below
pm.delete(new_end_joint.listRelatives(ad=1))
new_hierarchy = class_(start_joint=new_start_joint, end_joint=new_end_joint)
for j, nj in zip(self.joints, new_hierarchy.joints):
nj.rename("{prefix}{joint}{suffix}".format(prefix=prefix, suffix=suffix, joint=j.name()))
return new_hierarchy
示例5: create_stabilizer_parent
# 需要導入模塊: from pymel import core [as 別名]
# 或者: from pymel.core import rename [as 別名]
def create_stabilizer_parent(self):
"""creates the stabilizer parent
"""
# the new stabilizer parent should be at the origin of the original
# objects parent so that the keyframes of the object should not be altered
self._stabilizer_parent = pm.nodetypes.DagNode(
auxiliary.axial_correction_group(
self._object,
to_parents_origin=True
)
)
self._stabilizer_parent = pm.nodetypes.DagNode(
pm.rename(
self._stabilizer_parent,
self._object.name() + "_stabilizer_parent"
)
)
# connect it to the created nodes attribute
index = self._object.attr('pickedData.createdNodes').numElements()
self._stabilizer_parent.attr('message') >> \
self._object.attr('pickedData.createdNodes[' + str(index) + ']')
示例6: create_constrained_parent
# 需要導入模塊: from pymel import core [as 別名]
# 或者: from pymel.core import rename [as 別名]
def create_constrained_parent(self):
"""creates parents for the object
"""
# check if there is a stabilizerParent
try:
pm.nodetypes.DagNode(self._stabilizer_parent)
except pm.MayaNodeError:
return
self._constrained_parent = pm.nodetypes.DagNode(
auxiliary.axial_correction_group(self._stabilizer_parent))
self._constrained_parent = pm.nodetypes.DagNode(
pm.rename(self._constrained_parent,
self._object.name() + "_constrained_parent"))
index = self._object.attr('pickedData.createdNodes').numElements()
self._constrained_parent.attr('message') >> \
self._object.attr('pickedData.createdNodes[' + str(index) + ']')
示例7: create_spine
# 需要導入模塊: from pymel import core [as 別名]
# 或者: from pymel.core import rename [as 別名]
def create_spine(self, name_in, curve_in, frontAxis="z"):
#self._network = Network(name_in)
self._limbName = name_in
# You can change createion method with a Joint Chain Class
# JointChain(name_in, jointPositions)
# self.joint.orientChain
self.joints = SpineJoints(name_in, curve_in)
self.joints.orient_spine(frontAxis)
ikSolver = pm.ikHandle(sj=self.joints.startJoint,
ee=self.joints.endJoint,
tws="linear",
cra=True,
pcv=False,
ns=2,
sol="ikSplineSolver",
name=(name_in + "_IKSpine"))
self._ikHandle = pm.rename(ikSolver[0], (name_in + "_IK_Spine"))
self._effector = pm.rename(ikSolver[0],
(name_in + "_IK_SpineEffector"))
self._curve = Curve((name_in + "_IKSpineCurve"), ikSolver[2])
示例8: createFollicle
# 需要導入模塊: from pymel import core [as 別名]
# 或者: from pymel.core import rename [as 別名]
def createFollicle(target=None, param=[0.5,0.5], name="follicle"):
"""
Create follicle.
:param target: `PyNode` target that the follicle connected to
:param param: `list` [u, v] follicle uv parameter
:param name: `string` follicle name
:return: `PyNode` follicle ransform node
"""
follicle = pm.createNode("follicle")
follicle.parameterU.set(param[0])
follicle.parameterV.set(param[1])
if target:
targetShape = target.getShape()
targetShape.worldMatrix.connect(follicle.inputWorldMatrix)
if targetShape.nodeType() == "nurbsSurface":
targetShape.local.connect(follicle.inputSurface)
elif targetShape.nodeType() == "mesh":
targetShape.outMesh.connect(follicle.inputMesh)
folTransform = follicle.getParent()
follicle.outRotate.connect(folTransform.rotate)
follicle.outTranslate.connect(folTransform.translate)
pm.rename(folTransform, name)
return folTransform
示例9: on_action_nameChange
# 需要導入模塊: from pymel import core [as 別名]
# 或者: from pymel.core import rename [as 別名]
def on_action_nameChange(self, iRow, iCol, *args):
pCell = self.ui.tblData.item(iRow,iCol)
pData = pCell.data(QtCore.Qt.UserRole)
sCurPrefix = pData.nChildLoc.name().split("_")[0]
for sName in pData.__dict__:
pCurObj = pData.__dict__[sName]
sNewName = pCurObj.name().replace(sCurPrefix, args[0])
pymel.rename(pCurObj, sNewName)
#Change the axis connection of the system to connect in the good axis
示例10: addIkHandle
# 需要導入模塊: from pymel import core [as 別名]
# 或者: from pymel.core import rename [as 別名]
def addIkHandle(parent, name, chn, solver="ikRPsolver", poleV=None):
"""Creates and connect an IKhandle to a joints chain.
Arguments:
parent (dagNode): The parent for the IKhandle.
name (str): The node name.
chn (list): List of joints.
solver (str): the solver to be use for the ikHandel. Default
value is "ikRPsolver"
poleV (dagNode): Pole vector for the IKHandle
Returns:
dagNode: The IKHandle
>>> self.ikHandleUpvRef = pri.addIkHandle(
self.root,
self.getName("ikHandleLegChainUpvRef"),
self.legChainUpvRef,
"ikSCsolver")
"""
# creating a crazy name to avoid name clashing before convert to pyNode.
node = pm.ikHandle(n=name + "kjfjfklsdf049r58420582y829h3jnf",
sj=chn[0],
ee=chn[-1],
solver=solver)[0]
node = pm.PyNode(node)
pm.rename(node, name)
node.attr("visibility").set(False)
if parent:
parent.addChild(node)
if poleV:
pm.poleVectorConstraint(poleV, node)
return node
示例11: _create_shader
# 需要導入模塊: from pymel import core [as 別名]
# 或者: from pymel.core import rename [as 別名]
def _create_shader(self):
self._shader = pm.shadingNode('surfaceShader', asShader=1)
self._shader.rename(self.shader_name)
self._shader.outColor >> self.shading_engine.surfaceShader
# create the ramp
import maya.cmds as cmds
kelvin_ramp = pm.shadingNode('ramp', asTexture=1)
intensity_ramp = pm.shadingNode('ramp', asTexture=1)
intensity_ramp.attr('type').set(1)
intensity_ramp.interpolation.set(2)
intensity_ramp.colorEntryList[0].color.set(0, 0, 0)
intensity_ramp.colorEntryList[0].position.set(0)
kelvin_ramp.outColor >> intensity_ramp.colorEntryList[1].color
intensity_ramp.colorEntryList[1].position.set(0.707)
intensity_ramp.colorEntryList[2].color.set(1, 1, 1)
intensity_ramp.colorEntryList[2].position.set(1)
# set the colors of the ramp
kelvin_range = range(self.kelvin_min, self.kelvin_max, 1000)
total_colors = len(kelvin_range)
for i, kelvin in enumerate(kelvin_range):
color = cmds.arnoldTemperatureToColor(kelvin)
kelvin_ramp.colorEntryList[i].color.set(color)
kelvin_ramp.colorEntryList[i].position.set(float(i) / float(total_colors))
# connect ramp to the surfaceShaders.outColor
intensity_ramp.outColor >> self.shader.outColor
示例12: add_controller_shape
# 需要導入模塊: from pymel import core [as 別名]
# 或者: from pymel.core import rename [as 別名]
def add_controller_shape(cls):
selection = pm.ls(sl=1)
if len(selection) < 2:
return
objects = []
for i in range(0, (len(selection) - 1)):
objects.append(selection[i])
joints = selection[len(selection) - 1]
for i in range(0, len(objects)):
parents = pm.listRelatives(objects[i], p=True)
if len(parents) > 0:
temp_list = pm.parent(objects[i], w=1)
objects[i] = temp_list[0]
temp_list = pm.parent(objects[i], joints)
objects[i] = temp_list[0]
pm.makeIdentity(objects[i], apply=True, t=1, r=1, s=1, n=0)
temp_list = pm.parent(objects[i], w=True)
objects[i] = temp_list[0]
shapes = pm.listRelatives(objects, s=True, pa=True)
for i in range(0, len(shapes)):
temp_list = pm.parent(shapes[i], joints, r=True, s=True)
shapes[i] = temp_list[0]
joint_shapes = pm.listRelatives(joints, s=True, pa=True)
for i in range(0, len(joint_shapes)):
name = "%sShape%f" % (joints, (i + 1))
temp = ''.join(name.split('|', 1))
pm.rename(joint_shapes[i], temp)
pm.delete(objects)
pm.select(joints)
示例13: replace_controller_shape
# 需要導入模塊: from pymel import core [as 別名]
# 或者: from pymel.core import rename [as 別名]
def replace_controller_shape(cls):
selection = pm.ls(sl=1)
if len(selection) < 2:
return
objects = selection[0]
joints = selection[1]
shape = pm.listRelatives(objects, s=True)
joint_shape = pm.listRelatives(joints, s=True)
parents = pm.listRelatives(objects, p=True)
if len(parents):
temp_list = pm.parent(objects, w=True)
objects = temp_list
temp_list = pm.parent(objects, joints)
objects = temp_list[0]
pm.makeIdentity(objects, apply=True, t=1, r=1, s=1, n=0)
temp_list = pm.parent(objects, w=True)
objects = temp_list[0]
if len(joint_shape):
pm.delete(joint_shape)
for i in range(0, len(shape)):
name = "%sShape%f" % (joints, (i + 1))
shape[i] = pm.rename(shape[i], name)
temp_list = pm.parent(shape[i], joints, r=True, s=True)
shape[i] = temp_list[0]
pm.delete(objects)
pm.select(joints)
示例14: remove_colon_from_names
# 需要導入模塊: from pymel import core [as 別名]
# 或者: from pymel.core import rename [as 別名]
def remove_colon_from_names(cls):
selection = pm.ls(sl=1)
for item in selection:
temp = item.split(':')[-1]
pm.rename(item, temp)
pm.ls(sl=1)
示例15: remove_pasted
# 需要導入模塊: from pymel import core [as 別名]
# 或者: from pymel.core import rename [as 別名]
def remove_pasted(cls):
"""removes the string 'pasted__' from selected object names
"""
rmv_str = "pasted__"
[
obj.rename(obj.name().split('|')[-1].replace(rmv_str, ''))
for obj in pm.ls(sl=1)
if rmv_str in obj.name()
]