Skip to content

Commit 473aad7

Browse files
feat: add code to generate bat scripts to nova export
1 parent 83174da commit 473aad7

File tree

5 files changed

+137
-0
lines changed

5 files changed

+137
-0
lines changed

.bat

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
chcp 1252
2+
del \*.ifc
3+
4+
"C:\Program Files\Trimble\nova16\Nova.exe" /writeIfc:"sql-adznova.antec.local:NovaProjects::";"";""
5+
timeout /t 5 /nobreak
6+
ren \*Lueftung_alle*.ifc Lueftung_alle.ifc
7+
xcopy \Lueftung_alle.ifc "" /Y
8+

ifc_templates/tes1.ifc

Whitespace-only changes.

ifc_templates/test2.ifc

Whitespace-only changes.

ifc_templates/test3.ifc

Whitespace-only changes.

main.py

+129
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,129 @@
1+
def main():
2+
generate_batch_script()
3+
4+
5+
import os
6+
import tkinter as tk
7+
from tkinter import ttk
8+
9+
BASE_DIR = os.path.dirname(os.path.abspath(__file__))
10+
BASE_SQL_PATH = "sql-novatest.test.local:NovaProjects::"
11+
NOVA_VERSION = "Nova 17.1"
12+
13+
14+
def toggle_advanced_settings():
15+
global show_advanced
16+
show_advanced = not show_advanced
17+
update_advanced_settings()
18+
19+
20+
def update_advanced_settings():
21+
if show_advanced:
22+
advanced_settings_frame.grid()
23+
toggle_button.config(text="Hide Advanced Settings")
24+
else:
25+
advanced_settings_frame.grid_remove()
26+
toggle_button.config(text="Show Advanced Settings")
27+
28+
29+
def update_file_list():
30+
template_path = path_entry.get()
31+
if not template_path:
32+
template_path = BASE_DIR + "/ifc_templates"
33+
try:
34+
files = [
35+
f
36+
for f in os.listdir(template_path)
37+
if os.path.isfile(os.path.join(template_path, f))
38+
]
39+
ifc_template_combobox["values"] = files
40+
except FileNotFoundError:
41+
ifc_template_combobox["values"] = []
42+
43+
44+
def generate_batch_script():
45+
path = path_entry.get()
46+
project_hash = project_hash_entry.get()
47+
ifc_template = ifc_template_combobox.get()
48+
save_location = save_location_entry.get()
49+
50+
print(path, project_hash, ifc_template, save_location)
51+
52+
script_content = f"""chcp 1252
53+
del {path}\\*.ifc
54+
55+
"C:\\Program Files\\Trimble\\{NOVA_VERSION}\\Nova.exe" /writeIfc:"{BASE_SQL_PATH}{project_hash}";"{path}";"{ifc_template}"
56+
timeout /t 5 /nobreak
57+
58+
ren {path}\\*{project_hash}*.ifc {project_hash}.ifc
59+
60+
xcopy {path}\\{project_hash}.ifc "{save_location}" /Y
61+
"""
62+
63+
with open(os.path.join(save_location, "{}.bat".format(project_hash)), "w") as file:
64+
file.write(script_content)
65+
status_label.config(text="Batch Script Generated Successfully")
66+
67+
68+
root = tk.Tk()
69+
root.title("Batch Script Generator for Nova 17.1")
70+
71+
# IFC Template Selection
72+
tk.Label(root, text="IFC Template:").grid(row=0, column=0)
73+
ifc_template_combobox = ttk.Combobox(root)
74+
ifc_template_combobox.grid(row=0, column=1)
75+
ifc_template_combobox.bind("<Button-1>", lambda event: update_file_list())
76+
77+
# Temp Path to save IFCs Scripts
78+
tk.Label(root, text="Temp Path:").grid(row=1, column=0)
79+
path_entry = tk.Entry(root)
80+
path_entry.grid(row=1, column=1)
81+
82+
# Project ID from the SQL NOVA Server // Like: 45608B7B-FB6C-48D9-901B-4198E1E0413B
83+
tk.Label(root, text="Project ID:").grid(row=2, column=0)
84+
project_hash_entry = tk.Entry(root)
85+
project_hash_entry.grid(row=2, column=1)
86+
87+
# Save Location for the IFCs
88+
tk.Label(root, text="Save Location:").grid(row=3, column=0)
89+
save_location_entry = tk.Entry(root)
90+
save_location_entry.grid(row=3, column=1)
91+
92+
93+
# Generate Button
94+
generate_button = tk.Button(root, text="Generate Script", command=generate_batch_script)
95+
generate_button.grid(row=4, column=1)
96+
97+
# Status Label / Success or Error Message
98+
status_label = tk.Label(root, text="")
99+
status_label.grid(row=5, column=0, columnspan=2)
100+
101+
advanced_settings_frame = tk.Frame(root)
102+
advanced_settings_frame.grid(row=8, column=0, columnspan=2)
103+
104+
tk.Label(advanced_settings_frame, text="Nova Exe Path :").grid(row=1, column=0)
105+
nova_exe_entry = tk.Entry(advanced_settings_frame)
106+
nova_exe_entry.grid(row=1, column=1)
107+
108+
tk.Label(advanced_settings_frame, text="SQL Server Path :").grid(row=2, column=0)
109+
sql_server_entry = tk.Entry(advanced_settings_frame)
110+
sql_server_entry.grid(row=2, column=1)
111+
112+
toggle_button = tk.Button(
113+
root, text="Show Advanced Settings", command=toggle_advanced_settings
114+
)
115+
toggle_button.grid(row=0, column=2)
116+
117+
status_label = tk.Label(root, text="")
118+
status_label.grid(row=5, column=0, columnspan=2)
119+
120+
# Initial state of advanced settings
121+
show_advanced = False
122+
update_advanced_settings()
123+
124+
125+
root.mainloop()
126+
127+
128+
if __name__ == "__main__":
129+
main()

0 commit comments

Comments
 (0)