def transferUV(src, tgts, deleteHistory=False, *args):
"""
gets the shader and uv's from the src and assigns to the tgt objs (transfer uv's)
Args:
src (string): the object we're getting the shader and uv's FROM
tgts (list[strings]): the objects we're setting the shaders and uv's Return
deleteHistory (boolean): delete constructionHistory? Will delete non-deformer history. . .
TO:
None
"""
message = ""
if deleteHistory:
message = "Should I copy transfer UV's?\nWarning: 'deleteHistory' will (duh) remove history,\ntho it SHOULD keep deformer history."
if not deleteHistory:
message = "Should I copy transfer UV's?"
confirm = confirmDialog(message)
if confirm == "Yes":
if deleteHistory:
srcShp = [x for x in cmds.listRelatives(src, s=True) if "Orig" not in x][0]
for t in tgts:
intObj = ""
shps = cmds.listRelatives(t, s=True)
for shp in shps:
# ----------- clean this up to only get the upstream-most orig node
if cmds.getAttr("{0}.intermediateObject".format(shp)):
intObj = shp
break
if intObj:
print "transferring uvs to {0}.intermediateObject".format(intObj)
cmds.setAttr("{0}.intermediateObject".format(intObj), 0)
cmds.transferAttributes(srcShp, intObj, uvs=2, sampleSpace=4)
cmds.delete(intObj, constructionHistory=True)
cmds.setAttr("{0}.intermediateObject".format(intObj), 1)
else:
print "transferring uvs to {0} shape"
cmds.transferAttributes(srcShp, t, uvs=2, sampleSpace=4)
cmds.delete(t, ch=True)
else:
srcShp = [x for x in cmds.listRelatives(src, s=True) if "Orig" not in x][0]
for t in tgts:
cmds.transferAttributes(srcShp, t, uvs=2, sampleSpace=4)
else:
print "Transfer UVs cancelled!"
return()
评论列表
文章目录