替换reference,保留动画


import pymel.core as pm
sel = pm.selected()[0]
namespace_old = pm.referenceQuery(sel, ns=1).split(':')[-1]
curve = pm.ls('{}:*'.format(namespace_old), type='nurbsCurve')
anicurve = [i.getParent().listConnections(c=1, s=1, d=0, p=1, type=('animCurveTL','animCurveTA','animCurveTU')) for i in curve]
anicurve = [i for i in anicurve if i]
chujiu = pm.createReference(r'S:\Shared with groups\mtz\assets\chr\chujiu\rig\chujiu.rig.rig_lay.v015\chujiu.ma', namespace='chujiu')

for i in anicurve:
    for j in i:
        try:
            output_node = pm.PyNode(j[0].name().replace(namespace_old, chujiu.fullNamespace))
            input_node = pm.PyNode(j[1].name())
            input_node >> output_node
        except:
            print input_node,output_node

评论
  目录