本文整理汇总了Python中pymel.core.duplicate方法的典型用法代码示例。如果您正苦于以下问题:Python core.duplicate方法的具体用法?Python core.duplicate怎么用?Python core.duplicate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pymel.core
的用法示例。
在下文中一共展示了core.duplicate方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: hold_ctrl_shapes
# 需要导入模块: from pymel import core [as 别名]
# 或者: from pymel.core import duplicate [as 别名]
def hold_ctrl_shapes(ctrl, parent=None):
"""
Make a snapshot of all shapes of a specific ctrls.
"""
shapes = filter(lambda x: isinstance(x, pymel.nodetypes.CurveShape), ctrl.getShapes())
snapshot_transform = pymel.duplicate(ctrl, parentOnly=True, returnRootsOnly=True)[0]
for shape in shapes:
shape_snapshot = _duplicate_shape(shape)
tmp_transform = shape_snapshot.getParent()
shape_snapshot.setParent(snapshot_transform, s=True, r=True)
pymel.delete(tmp_transform)
if parent:
snapshot_transform.setParent(parent)
else:
snapshot_transform.setParent(world=True)
snapshot_transform.rename('{0}Snapshot'.format(ctrl.name()))
return snapshot_transform
示例2: duplicate
# 需要导入模块: from pymel import core [as 别名]
# 或者: from pymel.core import duplicate [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
示例3: readIkKwargs
# 需要导入模块: from pymel import core [as 别名]
# 或者: from pymel.core import duplicate [as 别名]
def readIkKwargs(cls, card, isMirroredSide, sideAlteration=lambda **kwargs: kwargs, kinematicType='ik'):
'''
Overriden to handle if a custom curve was given, which then needs to be duplicated, mirrored and
fed directly into the splineTwist.
'''
kwargs = cls.readKwargs(card, isMirroredSide, sideAlteration, kinematicType='ik')
if isMirroredSide:
if 'controlCountOrCrv' in kwargs and not isinstance( kwargs['controlCountOrCrv'], int ):
crv = kwargs['controlCountOrCrv']
crv = duplicate(crv)[0]
kwargs['controlCountOrCrv'] = crv
move( crv.sp, [0, 0, 0], a=True )
move( crv.rp, [0, 0, 0], a=True )
crv.sx.set(-1)
kwargs['duplicateCurve'] = False
return kwargs
示例4: duplicate_with_skin
# 需要导入模块: from pymel import core [as 别名]
# 或者: from pymel.core import duplicate [as 别名]
def duplicate_with_skin(nodes, parentNode=None):
#親子付けがあってもエラーはかないように修正
print nodes
# リストタイプじゃなかったらリストに変換する
if not isinstance(nodes, list):
nodes = [nodes]
dupObjs = []
for node in nodes:
#子供のノード退避用ダミーペアレントを用意
dummy = common.TemporaryReparent().main(mode='create')
common.TemporaryReparent().main(node,dummyParent=dummy, mode='cut')
#複製
dup = cmds.duplicate(node)[0]
#ウェイト転送メソッドをSimpleWeightコピペに変更
weight.SimpleWeightCopyPaste().main(node, mode='copy', saveName=__name__, weightFile=node)
weight.SimpleWeightCopyPaste().main(dup, mode='paste', saveName=__name__, weightFile=node)
#親子付けを戻す
common.TemporaryReparent().main(node,dummyParent=dummy, mode='parent')
#ダミーペアレントを削除
common.TemporaryReparent().main(dummyParent=dummy, mode='delete')
if parentNode is not None:
cmds.parent(dup, parentNode)
dupObjs.append(dup)
return dupObjs
#シーン内、もしくは入力メッシュ内にゼロポリゴンオブジェクトがあるかどうか調べる関数
示例5: instance
# 需要导入模块: from pymel import core [as 别名]
# 或者: from pymel.core import duplicate [as 别名]
def instance(self, source_transform_node):
"""instances the given nodes hierarchy
"""
# duplicate the given node
# then replace the instanceable nodes with instances
# find instanceable nodes in the node and dupNode
source_hierarchy = self.walk_hierarchy(source_transform_node)
# if there is no node in the sourceHierarchy just return
# the instance of the given node
if len(source_hierarchy) < 1:
dup_node = pm.duplicate(source_transform_node, ilf=1, rc=True)[0]
pm.select(dup_node)
return
dup_node = pm.duplicate(source_transform_node, rc=True)[0]
dup_hierarchy = self.walk_hierarchy(dup_node)
for i, node in enumerate(dup_hierarchy):
shape = node.getShape()
if shape is not None and isinstance(shape,
tuple(self._instanceables)):
# instance the corresponding sourceNode
source_node = source_hierarchy[i]
new_instance_node = pm.duplicate(source_node, ilf=True)[0]
pm.parent(new_instance_node, node.getParent(), r=False)
pm.delete(node)
pm.select(dup_node)
return dup_node
示例6: create_ik_hierarchy
# 需要导入模块: from pymel import core [as 别名]
# 或者: from pymel.core import duplicate [as 别名]
def create_ik_hierarchy(self):
"""Creates the ik hierarchy
"""
self.ik_hierarchy = self.base_hierarchy.duplicate(class_=JointHierarchy, suffix="_ik")
示例7: create_fk_hierarchy
# 需要导入模块: from pymel import core [as 别名]
# 或者: from pymel.core import duplicate [as 别名]
def create_fk_hierarchy(self):
"""Creates the fk hierarchy
"""
self.fk_hierarchy = self.base_hierarchy.duplicate(class_=JointHierarchy, suffix="_fk")
示例8: duplicate_with_connections
# 需要导入模块: from pymel import core [as 别名]
# 或者: from pymel.core import duplicate [as 别名]
def duplicate_with_connections(cls):
"""duplicates the selected nodes with connections to the network
"""
return pm.duplicate(ic=1, rr=1)
示例9: duplicate_input_graph
# 需要导入模块: from pymel import core [as 别名]
# 或者: from pymel.core import duplicate [as 别名]
def duplicate_input_graph(cls):
"""duplicates the selected nodes with all their inputs
"""
return pm.duplicate(un=1, rr=1)
示例10: unshape_parent_nodes
# 需要导入模块: from pymel import core [as 别名]
# 或者: from pymel.core import duplicate [as 别名]
def unshape_parent_nodes(cls):
"""Moves the shape node of a mesh to another transform node as a
children if the mesh node has other meshes under it. Essentially
cleaning the scene.
"""
mesh_nodes_with_transform_children = []
all_meshes = pm.ls(dag=1, type='mesh')
for node in all_meshes:
parent = node.getParent()
tra_under_shape = pm.ls(
parent.listRelatives(),
type='transform'
)
if len(tra_under_shape):
mesh_nodes_with_transform_children.append(parent)
for node in mesh_nodes_with_transform_children:
# duplicate the node
dup = pm.duplicate(node)[0]
# remove all descendents
all_descendents = dup.listRelatives(ad=1)
# remove the shape from the list
all_descendents.remove(dup.getShape())
pm.delete(all_descendents)
# parent under the original node
pm.parent(dup, node)
# remove the shape of the original node
pm.delete(node.getShape())
示例11: split_camera
# 需要导入模块: from pymel import core [as 别名]
# 或者: from pymel.core import duplicate [as 别名]
def split_camera(cls):
"""splits one camera to multiple cameras
"""
selection = pm.ls(sl=1, type=pm.nt.Transform)
if not selection:
raise RuntimeError("Please select at least one camera")
new_cameras = []
from anima.env.mayaEnv import camera_tools
for cam in selection:
cut_info = camera_tools.find_cut_info(cam)
for cut_in, cut_out in cut_info:
print(cut_in, cut_out)
# duplicate the original camera with input graph
dup_cam = pm.duplicate(cam, un=1)[0]
# remove all keyframes out of the cut range
# remove befor
pm.cutKey(dup_cam, time=(-1000, cut_in - 1))
# # remove after
pm.cutKey(dup_cam, time=(cut_out + 1, 100000))
# rename the new cam
dup_cam.rename("%s_#" % cam.name())
new_cameras.append(dup_cam)
# remove original camera
pm.delete(cam)
# select all new cameras
pm.select(new_cameras)
示例12: duplicateObject
# 需要导入模块: from pymel import core [as 别名]
# 或者: from pymel.core import duplicate [as 别名]
def duplicateObject(object):
#duplicate the object
dup = pm.duplicate(object)
return dup[0]
示例13: createSurfaceFromJoints
# 需要导入模块: from pymel import core [as 别名]
# 或者: from pymel.core import duplicate [as 别名]
def createSurfaceFromJoints(joints, name="surface", ibtCVNum=0, degree=3):
"""
Create a nurbs surface along the given joints.
nurbs CV position is defined by joint position.
:param joints: `list` list of joint nodes
:param name: `string` name of the built surface
:param ibtCVNum: `int` number of cv points added inbetween the joint position
:param degree: `int` nurbs surface degree
:return: `PyNode` result surface
"""
# build surface from joints, one span for each joint
auxCrv = createCurveFromJoint(joints, name+"_crv", ibtCVNum, degree)
startPos = joints[0].getTranslation(space="world")
endPos = joints[-1].getTranslation(space="world")
offDir = (om.MVector(*(startPos-endPos))^om.MVector(0,1,0)).normal()
if offDir.length() == 0: offDir = om.MVector(0,0,-1)
print startPos, endPos, offDir[0], offDir[1], offDir[2]
buildCrv1 = pm.duplicate(auxCrv)
pm.move(offDir.x*0.5, offDir.y*0.5, offDir.z*0.5, buildCrv1, r=1)
buildCrv2 = pm.duplicate(auxCrv)
pm.move(offDir.x*-0.5, offDir.y*-0.5, offDir.z*-0.5, buildCrv2, r=1)
auxSurf = pm.loft(buildCrv1, buildCrv2, n=name, ch=0, u=1, d=degree)[0]
pm.rebuildSurface(auxSurf, ch=0, su=1, du=1, dv=degree, sv=0)
pm.delete(auxCrv, buildCrv1, buildCrv2)
# auxSurf.setParent(0)
return auxSurf
示例14: duplicateJointChain
# 需要导入模块: from pymel import core [as 别名]
# 或者: from pymel.core import duplicate [as 别名]
def duplicateJointChain(rootJoint, replace=None, suffix=None):
"""
Duplicate the given joint chain.
:param rootJoint: `PyNode` root joint of the given joint chain
:param replace: `tuple` or `list` (old string, new string)
rename the duplicated joint chain by replacing string in given joint name
:param suffix: `string` rename the duplicated joint chain by adding suffix to the given joint name
:return: `list` list of joints in the duplicated joint chain. ordered by hierarchy
"""
srcJnts = getJointsInChain(rootJoint)
dupJnts = []
if not replace and not suffix:
raise ValueError("Please rename the duplicated joint chain.")
for i, srcJnt in enumerate(srcJnts):
newName = srcJnt.name()
if replace:
newName = newName.replace(replace[0], replace[1])
if suffix:
newName = "{0}_{1}".format(newName, suffix)
dupJnt = pm.duplicate(srcJnt, n=newName, po=1)[0]
dupJnts.append(dupJnt)
for attr in ['t', 'r', 's', 'jointOrient']:
pm.setAttr("{0}.{1}".format(dupJnt.name(), attr), pm.getAttr("{0}.{1}".format(srcJnt.name(), attr)))
if i>0:
dupJnt.setParent(dupJnts[i-1])
#
# for i, srcJnt in enumerate(srcJnts):
# if i==0: continue
# srcPar = pm.listRelatives(srcJnt, p=1)
# if srcPar:
# dupJnts[i].setParent(srcPar[0].name().replace(replace[0], replace[1]))
return dupJnts
示例15: duplicate_with_skin
# 需要导入模块: from pymel import core [as 别名]
# 或者: from pymel.core import duplicate [as 别名]
def duplicate_with_skin(nodes, parentNode=None):
#親子付けがあってもエラーはかないように修正
#print nodes
# リストタイプじゃなかったらリストに変換する
if not isinstance(nodes, list):
nodes = [nodes]
dupObjs = []
for node in nodes:
#子供のノード退避用ダミーペアレントを用意
dummy = common.TemporaryReparent().main(mode='create')
common.TemporaryReparent().main(node,dummyParent=dummy, mode='cut')
#複製
dup = cmds.duplicate(node)[0]
#ウェイト転送メソッドをSimpleWeightコピペに変更
weight.SimpleWeightCopyPaste().main(node, mode='copy', saveName=__name__, weightFile=node)
weight.SimpleWeightCopyPaste().main(dup, mode='paste', saveName=__name__, weightFile=node)
#親子付けを戻す
common.TemporaryReparent().main(node,dummyParent=dummy, mode='parent')
#ダミーペアレントを削除
common.TemporaryReparent().main(dummyParent=dummy, mode='delete')
if parentNode is not None:
cmds.parent(dup, parentNode)
dupObjs.append(dup)
return dupObjs
#シーン内、もしくは入力メッシュ内にゼロポリゴンオブジェクトがあるかどうか調べる関数