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