使用Python的ezdxf包,结合excel表中的坐标数据,绘制了变形图,表格,代码,结果如下:
DK41+175 | 左上偏距 | 左上高程 | 拱顶偏距 | 拱顶高程 | 右上偏距 | 右上高程 | |
422 | 上导第二层拱架完成 | -4.1500 | 432.7640 | 2.5360 | 436.0970 | 8.9410 | 432.9830 |
502 | 中左 | -4.2250 | 431.6110 | 2.463 | 435.5420 | 8.8860 | 432.4800 |
505 | 中右 | -4.2250 | 431.4890 | 2.463 | 435.4140 | 8.8860 | 432.3400 |
513 | 下左 | -4.0050 | 431.7810 | 2.4640 | 435.2430 | 8.8730 | 432.1680 |
513 | 下右 | -4.0050 | 431.7810 | 2.4640 | 435.2430 | 8.8730 | 432.1680 |
524 | 仰拱开挖 | -4.2020 | 431.4900 | 2.4450 | 435.1350 | 8.8580 | 432.0360 |
521 | 仰拱施作 | -4.2030 | 431.4980 | 2.4460 | 435.1440 | 8.8580 | 432.0450 |
521 | 仰拱填充 | -4.2030 | 431.4980 | 2.4460 | 435.1440 | 8.8580 | 432.0450 |
桩号 | DK41+170 | 左上偏距 | 左上高程 | 拱顶偏距 | 拱顶高程 | 右上偏距 | 右上高程 |
423 | 上导第二层拱架完成 | -4.0000 | 433.1260 | 2.5180 | 436.2240 | 9.1580 | 432.7990 |
505 | 中左 | -3.9280 | 432.5530 | 2.5150 | 435.8470 | 9.1480 | 432.3630 |
511 | 中右 | -3.9030 | 432.3970 | 2.4950 | 435.6880 | 9.1780 | 432.2580 |
517 | 下左 | -3.8920 | 432.0230 | 2.4530 | 435.3750 | 9.1740 | 432.0220 |
518 | 下右 | -3.9560 | 432.1540 | 2.4510 | 435.3440 | 9.1740 | 431.9920 |
519 | 仰拱开挖 | -3.9540 | 432.1070 | 2.4480 | 435.3050 | 9.1690 | 431.9590 |
525 | 仰拱施作 | -3.9500 | 432.0610 | 2.4490 | 435.2300 | 9.1650 | 431.8980 |
526 | 仰拱填充 | -3.9480 | 432.0580 | 2.4460 | 435.2250 | 9.1610 | 431.8940 |
import ezdxf
import xlrd
from ezdxf import math
left_x_list = [] #左上list,拱顶list,右上list,每个断面有8组数据
left_y_list = []
top_x_list=[]
top_y_list=[]
right_x_list=[]
right_y_list=[]
duan_mian_shu = 2 #在此规定断面数
duan_mian_list = ['DK41+175','DK41+170']
top_origin_y = [] #拱顶初始预留沉降量list,每个断面有一个数据
color_index=[150,130,110,70,50,40,30,10] #ACI 颜色参数,分别用于表示8个阶段
gap = 10 #计算表格中两个表的纵向间隔
table = xlrd.open_workbook('/Volumes/MAC_DATA/张吉怀隧道软岩大变形[更新]/邓家坡资料/五工区1#横洞量测数据/一计算表.xlsx')
sheet = table.sheet_by_name('Sheet2')
title_location=(-4,420) #绘图title位置
a= math.ConstructionArc() #实例化ConstructionArc类的对象,用于使用其 3点画弧线 方法
for j in range(0,duan_mian_shu):
doc = ezdxf.readfile('OriginDxf.dxf')
msp = doc.modelspace()
left_x_list.clear() #j表示每个断面,在开始一个断面的绘图前,清除之前的坐标数据
left_y_list.clear()
top_x_list.clear()
top_y_list.clear()
right_x_list.clear()
right_y_list.clear()
top_origin_y.append(sheet.cell(1+j*gap,8).value) #将拱顶初始沉降量加入此list
for i in range(0,8):
left_x = sheet.cell(int((i+1)+j*gap),2).value #将每个cell的值输入坐标list
left_y = sheet.cell(int((i+1)+j*gap),3).value
top_x = sheet.cell(int((i+1)+j*gap),4).value
top_y = sheet.cell(int((i+1)+j*gap), 5).value
right_x = sheet.cell(int((i+1)+j*gap), 6).value
right_y = sheet.cell(int((i+1)+j*gap), 7).value
left_x_list.append(left_x)
left_y_list.append(left_y)
top_x_list.append(top_x)
top_y_list.append(top_y)
right_x_list.append(right_x)
right_y_list.append(right_y)
b = a.from_3p(start_point=(right_x_list[i], right_y_list[i]), #使用变量b接收ConstractionArc类对象,以使用其计算结果
def_point=(top_x_list[i], top_y_list[i]),
end_point=(left_x_list[i], left_y_list[i]))
msp.add_arc(center=b.center,
radius=b.radius,
start_angle=b.start_angle,
end_angle=b.end_angle,
dxfattribs={'color': int(color_index[i])}) #绘制一个断面的8个弧线
msp.add_circle((right_x_list[i], right_y_list[i]), radius=0.05) #在每个测点绘制圆圈
msp.add_circle((top_x_list[i], top_y_list[i]), radius=0.05)
msp.add_circle((left_x_list[i], left_y_list[i]), radius=0.05)
msp.add_line(start=(top_x_list[0], top_y_list[0]), #在初始的拱顶点向下画辅助线,便于后处理移动二衬图
end=(top_x_list[0], top_y_list[0] - top_origin_y[j] / 1000))
msp.add_text(text='邓家坡隧道1#横洞小里程{}断面上导变形图'.format(duan_mian_list[j]),
dxfattribs={'height':0.65}).set_pos(p1=title_location,align='LEFT')
doc.saveas('Plot/testPlot{}.dxf'.format(str(j+1)))
print(left_x_list)
print(left_y_list)
print(top_x_list)
print(top_y_list)
print(right_x_list)
print(right_y_list)