Hi everyone! I have noticed that when trying to parse XML files with multiple links in MeshesSL, I often get .dae files that are unable to be read properly by the viewer when uploading. I solved this problem by creating a python script that separates a multi-link xml file into separate xml files, each only containing the info for a single mesh.
To use it, just install python and copy save the script to the folder containing your xml file. Rename your xml file as 'source.xml' and run the script c:
To use it, just install python and copy save the script to the folder containing your xml file. Rename your xml file as 'source.xml' and run the script c:
#This parameter determines whether link names keep their original names or not.
#Set to False to name each link numerically instead
RENAME_LINKS = True
FILE_START = '\n \n '
LINK_NAME = ' name '
f = open('source.xml')
ftext = f.read()
f.close()
flist = ftext.split('\n')
#print(len(flist))
#spaces of 326
newString = ''
imesh = 1
skip = False
for i in range(2,len(flist)-1):
#print(flist[i])
add = flist[i] + '\n'
if not (flist[i] == ' parent ' or flist[i-1] == ' parent '):
if flist[i - 1] == LINK_NAME and RENAME_LINKS == True:
add = ' ' + 'link{}'.format(imesh) + ' \n'
newString += add
else:
newString += add
if i < len(flist):
end = ' '
beginPlus1 = ' '):
#print('true')
newfile = open('m{}.xml'.format(imesh),'w+')
output = FILE_START + newString + FILE_END
newfile.write(output)
newfile.close()
newString = ''
imesh += 1
#print(flist[i])
print('Finished')