Skip to content

Instantly share code, notes, and snippets.

@gabosalinas
Created September 19, 2017 03:35
Show Gist options
  • Save gabosalinas/b1f578e6e06a113543dbb1ad4732c5f6 to your computer and use it in GitHub Desktop.
Save gabosalinas/b1f578e6e06a113543dbb1ad4732c5f6 to your computer and use it in GitHub Desktop.
CopyPasteAtts
#Copia atributos para pegarlos despues en otro/s objetos. Selecciona el transform del shape en el que estas interesado.
#It copies attributes for later pasting on other objects. Select the shape's transform you are interested in.
import maya.cmds as mc
s = mc.ls(sl=1)
if s:
sel = s[0]
if mc.nodeType( sel ) == 'transform' :
sel = mc.listRelatives(sel,s=1)[0]
atts=mc.listAttr(sel)
atts.sort()
valores = {} #diccionario de atributos con sus valores.
attsScaneados = 0
attsScaneadosStr = ''
for a in atts: #GET valores.
if a != 'attributeAliasList':
try:
valores[a] = mc.getAttr(sel+'.'+a)
attsScaneados += 1
except:
pass
attsExceptuados = list(set( atts ) - set( valores.keys() )) # armo reporte de exceptuados.
for a in attsExceptuados:
attsScaneadosStr += a + ' \n '
print ( '\n' + '*' * 100 + '\n' + '*' * 100) # reporte.
print ( ' ATRIBUTOS NO COPIADOS // UNCOPIED ATTRIBUTES:' + ' \n ' + '-'*45)
print ( attsScaneadosStr )
mc.warning ( 'Copiados ' + str(attsScaneados) + ' atributos de un total de ' + str(len(atts)) + '. // Copied ' + str(attsScaneados) + ' attributes of ' + str(len(atts)) )
else:
mc.warning ('NO HAY SELECCION. // NO SELECTION.' )
import maya.cmds as mc
sele=mc.ls(sl=1)
for sel in sele:
if mc.nodeType( sel ) == 'transform' :
sel = mc.listRelatives(sel,s=1)[0]
print 'Pegando valores a: ', sel
for a in atts: #SET valores.
try:
mc.setAttr(sel+'.'+a, valores[a])
except:
pass
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment