修正 scr脚本的bug。
This commit is contained in:
parent
1387aa277e
commit
dc7cb8fc8c
15
cad.py
15
cad.py
|
|
@ -9,16 +9,19 @@ def convert_dxf_to_dwg(dxf_files: List[str]):
|
|||
dir_path = os.path.dirname(first_dwg_file)
|
||||
script_path = f"{dir_path}/batch.scr"
|
||||
with open(script_path, "w", encoding="ansi") as f:
|
||||
for dxf in dxf_files:
|
||||
f.write("FILEDIA 0\n")
|
||||
f.write("FILEDIA 0\n")
|
||||
for ind, dxf in enumerate(dxf_files):
|
||||
f.write(f'_open "{dxf}"\n')
|
||||
file_name_path, _ = os.path.splitext(dxf)
|
||||
new_dwg_name = f'{file_name_path}.dwg'
|
||||
new_dwg_name = f"{file_name_path}.dwg"
|
||||
if os.path.exists(new_dwg_name):
|
||||
os.remove(new_dwg_name)
|
||||
f.write(f'saveas 2004 "{new_dwg_name}"\n')
|
||||
f.write("FILEDIA 1\n")
|
||||
f.write(f"_close\n")
|
||||
f.write("_exit ")
|
||||
if ind == len(dxf_files) - 1:
|
||||
f.write("FILEDIA 1\n") # 最后一个回复打开dialog
|
||||
f.write("qquit\n")
|
||||
else:
|
||||
f.write(f"_close\n")
|
||||
# f.write("qquit\n")
|
||||
cmd = rf'"{cad_file_path}" /b "{script_path}"'
|
||||
subprocess.Popen(cmd)
|
||||
|
|
|
|||
34
dem.py
34
dem.py
|
|
@ -49,7 +49,7 @@ class Dem:
|
|||
|
||||
def write(self):
|
||||
# TODO:不应该设置缩放因数
|
||||
dxfs=[]
|
||||
dxfs = []
|
||||
zoom_factor = 1
|
||||
excel_pfs = self._read_path_file()
|
||||
segments = []
|
||||
|
|
@ -173,20 +173,22 @@ class Dem:
|
|||
dm_msp.add_polyline2d(tree_line, dxfattribs={"color": 5})
|
||||
dm_whole_accumulative_distance += x_axis[-1]
|
||||
os.makedirs(out_dxf_file_dir, exist_ok=True)
|
||||
ezdxf.options.set(
|
||||
"odafc-addon",
|
||||
"win_exec_path",
|
||||
"d:/ProgramFiles/ODAFileConverter/ODAFileConverter.exe",
|
||||
)
|
||||
from ezdxf.addons.odafc import export_dwg
|
||||
# ezdxf.options.set(
|
||||
# "odafc-addon",
|
||||
# "win_exec_path",
|
||||
# "d:/ProgramFiles/ODAFileConverter/ODAFileConverter.exe",
|
||||
# )
|
||||
# TODO 去掉odafc依赖
|
||||
# from ezdxf.addons.odafc import export_dwg
|
||||
|
||||
# export_dwg(
|
||||
# dm_doc,
|
||||
# f"{out_dxf_file_dir}/D{100+int(start_point_name[1:])}.dwg",
|
||||
# replace=True,
|
||||
# ) # 写断面文件
|
||||
dm_doc.saveas(f"{out_dxf_file_dir}/D{100+int(start_point_name[1:])}.dxf",)
|
||||
dxfs.append(f"{out_dxf_file_dir}/D{100+int(start_point_name[1:])}.dxf")
|
||||
dm_doc_dxf = f"{out_dxf_file_dir}/D{100+int(start_point_name[1:])}.dxf"
|
||||
dm_doc.saveas(dm_doc_dxf)
|
||||
dxfs.append(dm_doc_dxf)
|
||||
# 写Z文件
|
||||
z_file_path = f"{out_dxf_file_dir}/ZD{100+int(start_point_name[1:])}"
|
||||
with open(z_file_path, "w") as z_file:
|
||||
|
|
@ -275,12 +277,14 @@ class Dem:
|
|||
# f"{out_dxf_file_dir}/DA.dwg",
|
||||
# replace=True,
|
||||
# )
|
||||
dm_whole_doc.saveas(f"{out_dxf_file_dir}/DA.dxf")
|
||||
dm_whole_doc_dxf = f"{out_dxf_file_dir}/DA.dxf"
|
||||
dm_whole_doc.saveas(dm_whole_doc_dxf)
|
||||
# cad.convert_dxf_to_dwg([f"{out_dxf_file_dir}/DA.dxf"])
|
||||
dxfs.append(f"{out_dxf_file_dir}/DA.dxf")
|
||||
dxfs.append(dm_whole_doc_dxf)
|
||||
# 写平面文件
|
||||
plate_doc.saveas(f"{out_dxf_file_dir}/plate.dxf")
|
||||
dxfs.append(f"{out_dxf_file_dir}/plate.dxf")
|
||||
plate_doc_dxf = f"{out_dxf_file_dir}/plate.dxf"
|
||||
plate_doc.saveas(plate_doc_dxf)
|
||||
dxfs.append(plate_doc_dxf)
|
||||
cad.convert_dxf_to_dwg(dxf_files=dxfs)
|
||||
|
||||
def get_elevation(self, site_x_y):
|
||||
|
|
@ -376,8 +380,8 @@ class Dem:
|
|||
) ** 0.5
|
||||
dem_resolution = self._dem_resolution # dem的精度
|
||||
# TODO:设定为5m 1个点。
|
||||
# n = round(path_length / dem_resolution)
|
||||
n = round(path_length / 5)
|
||||
n = round(path_length / dem_resolution)
|
||||
# n = round(path_length / 5)
|
||||
center_point_x = np.linspace(point_x_s, point_x_e, n, endpoint=True)
|
||||
center_point_y = np.linspace(point_y_s, point_y_e, n, endpoint=True)
|
||||
# 计算左右边线
|
||||
|
|
|
|||
Loading…
Reference in New Issue