fix #24
This commit is contained in:
parent
49de97160c
commit
c7a417b191
@ -17,8 +17,8 @@ class Reload(inkex.EffectExtension):
|
|||||||
if currentDoc == "":
|
if currentDoc == "":
|
||||||
self.msg("Your document is not saved as a permanent file yet. Cannot reload.")
|
self.msg("Your document is not saved as a permanent file yet. Cannot reload.")
|
||||||
exit(1)
|
exit(1)
|
||||||
|
|
||||||
originalRoot = self.document.getroot()
|
originalRoot = self.document.getroot()
|
||||||
originalNamedview = self.svg.namedview
|
originalNamedview = self.svg.namedview
|
||||||
originalDefs = originalRoot.find("{http://www.w3.org/2000/svg}defs")
|
originalDefs = originalRoot.find("{http://www.w3.org/2000/svg}defs")
|
||||||
originalRoot.clear() #drop all children and attributes from root
|
originalRoot.clear() #drop all children and attributes from root
|
||||||
@ -33,24 +33,26 @@ class Reload(inkex.EffectExtension):
|
|||||||
except Exception as e:
|
except Exception as e:
|
||||||
inkex.utils.debug("Malformed file: {}".format(e))
|
inkex.utils.debug("Malformed file: {}".format(e))
|
||||||
exit(1)
|
exit(1)
|
||||||
|
|
||||||
copyRoot = doc.getroot()
|
copyRoot = doc.getroot()
|
||||||
copyNamedview = copyRoot.find(inkex.addNS('namedview', 'sodipodi'))
|
copyNamedview = copyRoot.find(inkex.addNS('namedview', 'sodipodi'))
|
||||||
copyDefs = copyRoot.find("{http://www.w3.org/2000/svg}defs")
|
copyDefs = copyRoot.find("{http://www.w3.org/2000/svg}defs")
|
||||||
for child in copyRoot.getchildren():
|
for child in copyRoot.getchildren():
|
||||||
originalRoot.append(child)
|
originalRoot.append(child)
|
||||||
|
|
||||||
#update all attributes in originalSVG
|
#update all attributes in originalSVG
|
||||||
for copyAttrib in copyRoot.attrib:
|
for copyAttrib in copyRoot.attrib:
|
||||||
originalRoot.attrib[copyAttrib] = copyRoot.attrib[copyAttrib]
|
originalRoot.attrib[copyAttrib] = copyRoot.attrib[copyAttrib]
|
||||||
|
|
||||||
#update all attributes in originalNamedview
|
#update all attributes in originalNamedview
|
||||||
for copyAttrib in copyNamedview.attrib:
|
if copyNamedview is not None:
|
||||||
originalNamedview.attrib[copyAttrib] = copyNamedview.attrib[copyAttrib]
|
for copyAttrib in copyNamedview.attrib:
|
||||||
|
originalNamedview.attrib[copyAttrib] = copyNamedview.attrib[copyAttrib]
|
||||||
|
|
||||||
#update all attributes in originalDefs
|
#update all attributes in originalDefs
|
||||||
for copyAttrib in copyDefs.attrib:
|
if copyDefs is not None:
|
||||||
originalDefs.attrib[copyAttrib] = copyDefs.attrib[copyAttrib]
|
for copyAttrib in copyDefs.attrib:
|
||||||
|
originalDefs.attrib[copyAttrib] = copyDefs.attrib[copyAttrib]
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
Reload().run()
|
Reload().run()
|
Loading…
Reference in New Issue
Block a user