Skip to content

Instantly share code, notes, and snippets.

@Roumenov
Created August 20, 2022 08:14
Show Gist options
  • Save Roumenov/05beda10b5ce60c988123b660f7eaf28 to your computer and use it in GitHub Desktop.
Save Roumenov/05beda10b5ce60c988123b660f7eaf28 to your computer and use it in GitHub Desktop.
just trying to get the xml files for skinweights
import pymel.core as pm
import vo_maya.core.vo_export as voe
reload(voe)
def weights_to_xml(object, xmlpath):
xmlfilename = object.name().split(':')[1] + ".xml"
pm.deformerWeights(xmlfilename, path = xmlpath, ex = 1, deformer = object.listHistory(type = 'skinCluster')[0])
def xml_to_weights(filename, xmlpath):
meshname = filename.split('.')[0]
meshtarget = pm.ls(meshname, r =1, sns = 0)[0]
pm.deformerWeights(filename, path = xmlpath, im = 1, m = "index", deformer = meshtarget.listHistory(type = 'skinCluster')[0])
print("%s imported")%(filename)
xmlpath = r"Z:/p4v/PotionomicsSourceAssets/Art_sourcefiles/Characters/scenes/Models/GenChar/costume/socialite_male"
importpath = r"Z:/p4v/PotionomicsSourceAssets/Art_sourcefiles/Characters/scenes/Models/GenChar/costume/merchant/genchar_merchant_shirt_skirt_mesh.xml"
filename = importpath.split('/')[-1].split('.')[0]
meshtarget = pm.ls(filename, r =1, sns = 0)[0]
pm.deformerWeights("genchar_merchant_shirt_skirt_mesh.xml", path = xmlpath, im = 1, m = "nearest", deformer = meshtarget.listHistory(type = 'skinCluster')[0])
#export
meshes = pm.ls(sl=1)
[weights_to_xml(item, xmlpath) for item in meshes if item.listHistory(type = 'skinCluster')]
#import
xmlsources = os.listdir(xmlpath)
[xml_to_weights(filename, xmlpath) for filename in xmlsources if filename.endswith('.xml')]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment