Update Pier_v1 project
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
1 parent
f25e36c050
commit
ad73ddec2b
2476 files changed
+3423
-4902
No files matched your search
@@ -0,0 +1,45 @@
|
||||
"""Run the existing extraction API headlessly and stream JSON lines to the popup."""
|
||||
import argparse
|
||||
import json
|
||||
from pathlib import Path
|
||||
import sys
|
||||
|
||||
|
||||
def emit(kind, **values):
|
||||
print(json.dumps(dict(type=kind, **values), ensure_ascii=False), flush=True)
|
||||
|
||||
|
||||
def main():
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument('mode', choices=['choose', 'extract'])
|
||||
parser.add_argument('folder', nargs='?')
|
||||
parser.add_argument('--output')
|
||||
args = parser.parse_args()
|
||||
if args.mode == 'choose':
|
||||
import tkinter as tk
|
||||
from tkinter import filedialog
|
||||
root = tk.Tk()
|
||||
root.withdraw()
|
||||
root.attributes('-topmost', True)
|
||||
try:
|
||||
folder = filedialog.askdirectory(parent=root, title='DWG 도면이 들어 있는 폴더 선택')
|
||||
finally:
|
||||
root.destroy()
|
||||
emit('folder', folder=folder)
|
||||
return
|
||||
if not args.folder or not args.output:
|
||||
raise ValueError('도면 폴더와 결과 경로가 필요합니다.')
|
||||
project = Path(__file__).resolve().parent.parent
|
||||
sys.path.insert(0, str(project / '도면추출'))
|
||||
from integration.bridge_extract import extract_folder
|
||||
result = extract_folder(args.folder, output_dir=args.output,
|
||||
on_progress=lambda message: emit('log', message=message))
|
||||
emit('result', result=result.to_dict(include_data=False))
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
try:
|
||||
main()
|
||||
except Exception as error:
|
||||
emit('error', message=str(error))
|
||||
sys.exit(1)
|
||||
Reference in new issue
Block a user