Created
August 20, 2022 08:14
-
-
Save Roumenov/05beda10b5ce60c988123b660f7eaf28 to your computer and use it in GitHub Desktop.
just trying to get the xml files for skinweights
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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