from tkinter import filedialog
from xml.dom.minidom import parse
txtPath = r"C:\Users\HZTTCH\Desktop\两天相控数据合并处理1_杭州坐标系.txt"
with open(txtPath,"r") as f:
text = f.readlines()
textList = [x.replace("\n","").split(",") for x in text]
print(textList)
xmlfile = r"C:\Users\HZTTCH\Desktop\新建文件夹 (2)\controlpoint44.xml"
dom = parse(xmlfile)
books = dom.getElementsByTagName('ControlPoint')
for book in books:
titles = book.getElementsByTagName('Name')
pts = book.getElementsByTagName('Position')
name = titles.item(0).firstChild.data
for tt in textList:
if tt[0] == name:
newx = tt[2]
newy = tt[3]
newz = tt[4]
for pt in pts:
ptx = book.getElementsByTagName('x')
pty = book.getElementsByTagName('y')
ptz = book.getElementsByTagName('z')
ptx[0].firstChild.data = newx
pty[0].firstChild.data = newy
ptz[0].firstChild.data = newz
fp = open(xmlfile, 'w', encoding='utf-8')
dom.writexml(fp, indent='', addindent='', newl='', encoding='utf-8')
fp.close()
重建大师批量替换相控点
最新推荐文章于 2024-05-18 20:47:10 发布