Second Life Copybot
Python script for separating linksets easily. - Printable Version

+- Second Life Copybot (https://secondlifecopybot.com)
+-- Forum: THE LOUNGE (https://secondlifecopybot.com/forum-24.html)
+--- Forum: General Discussion (https://secondlifecopybot.com/forum-25.html)
+--- Thread: Python script for separating linksets easily. (/thread-22366.html)



Python script for separating linksets easily. - Huggypie - 01-11-2019

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:#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'
FILE_END = '
\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 = ' '
if (flist[i] == end and flist[i+2] == beginPlus1) or (flist[i+1] == '
'):
#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')



RE: Python script for separating linksets easily. - kriptonic - 02-03-2019

I miss the old days copyboting was so easy and mesh was only just starting to come in