--created by har1sf0x on 28/09/2017, Greece fn applySkinDataFromMayaXML skinMod filename = ( --inputs: skinmod: skin modifier with bones addeds | filename: the fullpath of the .xml file generated from maya (Deform/Export Weights...) --applies the skin data of the .xml file to the skinMod if classOf skinMod != skin do ( return messageBox "The modifier provided is not of class skin." title:"Input Error" ) --Create a list of the bones in the skinMod bnList = #() for i = 1 to skinOps.GetNumberBones skinMod do ( append bnList (skinOps.GetBoneName skinMod i 0) ) --Load the xml assembly dotNet.loadAssembly "system.xml" --Create an xml document object. xmlDoc = dotNetObject "system.xml.xmlDocument" -- If the file exists then load it if doesFileExist filename then ( --Load the .xml file xmlDoc.load filename --Check to make sure the xmlDoc has a root element named "deformerWeight" docElem = xmlDoc.documentElement if docElem != undefined and docElem.name == "deformerWeight" then ( --Iterate through the children of the root ("deformerWeight") and get the ones named "weights" for i = 0 to docElem.childNodes.count - 1 where (docElem.childNodes.itemOf[i]).name == "weights" do ( --Get the name of the bone --> bnName bnName = (docElem.childNodes.itemOf[i].GetAttributeNode "source").value --Check if the current bone name exists in the bone list of the skin modifier bnID = findItem bnList bnName if bnId != 0 then ( --Iterate through the children of each "weights" element and get the ones named "point" for j = 0 to (docElem.childNodes.itemOf[i]).childNodes.count - 1 where ((docElem.childNodes.itemOf[i]).childNodes.itemOf[j]).name == "point" do ( --Get the value of the class index --> vertID vertID = (((docElem.childNodes.itemOf[i]).childNodes.itemOf[j].GetAttributeNode "index").value) as integer + 1 --Get the value of the class value --> weight weight = (((docElem.childNodes.itemOf[i]).childNodes.itemOf[j].GetAttributeNode "value").value) as float --Set the weight of the skinMod skinOps.SetVertexWeights skinMod vertID bnID weight ) ) else ( --If the bone does not exist --> messageBox messageBox ("The bone \"" + bnName + "\" does not exist in the skin modifier.") title:"Bone is missing" ) ) ) else ( --Error: file is not of proper format (maya 2018 on 28/09/2017) messageBox ("The file \"" + filename + "\" does not seam to be of proper format.") title:"File Error" ) ) else ( --Error: file does not exist messageBox ("The file \"" + filename + "\" does not exist.") title:"File Error" ) ok )