Skip to content

Instantly share code, notes, and snippets.

@raspberrypisig
Created August 17, 2021 06:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save raspberrypisig/74e774ae2f3e5b5c544b3aab82219e7b to your computer and use it in GitHub Desktop.
Save raspberrypisig/74e774ae2f3e5b5c544b3aab82219e7b to your computer and use it in GitHub Desktop.
import easygui
import xml.etree.ElementTree as ET
import sys
easygui.msgbox('Welcome. Click OK to select a DAE file to fix', 'DAE fix units')
inputfile = easygui.fileopenbox()
ET.register_namespace('', "http://www.collada.org/2005/11/COLLADASchema")
tree = ET.parse(inputfile)
root = tree.getroot()
assetTag = root[0]
#print(assetTag)
'''
Want to append this to the asset tag as child element
<unit name="millimeters" meter="0.001"/>
'''
unitTag = ET.Element('unit')
unitTag.set('name', 'millimeters')
unitTag.set('meter', '0.001')
assetTag.append(unitTag)
newfile = inputfile.replace('.dae', '') + '-converted.dae'
tree.write(newfile)
easygui.msgbox("Fix successful. New file created: " + newfile)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment