Launch.json angepasst, sodass draw cable dxf from easy to new dxf ein neues dxf mit namen easy_cables schriebt. getexdraw.bat angepasst, sodass bei routing ein graph angezeigt wird und gespeichert werden kann (testweise). drawdxf.py angepasst, sodass eine excel ausgabe mit 2 Worksheets geschrieben wird.
This commit is contained in:
Vendored
+2
-1
@@ -91,7 +91,8 @@
|
|||||||
"args": [
|
"args": [
|
||||||
"--json",
|
"--json",
|
||||||
"easy.json",
|
"easy.json",
|
||||||
"--new"
|
"--new",
|
||||||
|
"easy_cables"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|||||||
+2
-2
@@ -1,4 +1,4 @@
|
|||||||
@echo off
|
REM @echo off
|
||||||
|
|
||||||
if [%1]==[] goto usage
|
if [%1]==[] goto usage
|
||||||
for /F %%i in ("%1") do set FILENAME=%%~ni
|
for /F %%i in ("%1") do set FILENAME=%%~ni
|
||||||
@@ -6,7 +6,7 @@ for /F %%i in ("%1") do set FILENAME=%%~ni
|
|||||||
echo --hole Positionen
|
echo --hole Positionen
|
||||||
call getpositions.bat --filename %1 -s -r -w %1
|
call getpositions.bat --filename %1 -s -r -w %1
|
||||||
echo --erzeuge Graph mit Routing
|
echo --erzeuge Graph mit Routing
|
||||||
call routing.bat --filename %FILENAME%.json -w todraw.json
|
call routing.bat --filename %FILENAME%.json -w todraw.json -g
|
||||||
echo --zeichne Kabel in dxf Datei
|
echo --zeichne Kabel in dxf Datei
|
||||||
call draw_dxf.bat --filename todraw.json --new %FILENAME%_cables.dxf
|
call draw_dxf.bat --filename todraw.json --new %FILENAME%_cables.dxf
|
||||||
|
|
||||||
|
|||||||
+34
-1
@@ -5,7 +5,10 @@ import os.path
|
|||||||
from dataclasses import dataclass, asdict, fields
|
from dataclasses import dataclass, asdict, fields
|
||||||
from dacite import from_dict
|
from dacite import from_dict
|
||||||
from typing import List
|
from typing import List
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
|
from openpyxl import Workbook
|
||||||
|
import math
|
||||||
|
from collections import defaultdict
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -19,6 +22,7 @@ class Point:
|
|||||||
class Polyline:
|
class Polyline:
|
||||||
id: str
|
id: str
|
||||||
coords: List[Point]
|
coords: List[Point]
|
||||||
|
length: float
|
||||||
|
|
||||||
def to_tuple(self):
|
def to_tuple(self):
|
||||||
ret = list()
|
ret = list()
|
||||||
@@ -70,6 +74,11 @@ def new_dxf(json_file, out_path, dxf_file=False):
|
|||||||
|
|
||||||
doc.saveas(out_path)
|
doc.saveas(out_path)
|
||||||
|
|
||||||
|
# Hier für Excel Export
|
||||||
|
excel_path = out_path.replace(".dxf", "_kabellaengen.xlsx")
|
||||||
|
write_excel_from_json(anlage, excel_path)
|
||||||
|
|
||||||
|
|
||||||
def check_file_in_work(work_dir, filename):
|
def check_file_in_work(work_dir, filename):
|
||||||
fexists = True
|
fexists = True
|
||||||
if not os.path.exists(filename):
|
if not os.path.exists(filename):
|
||||||
@@ -80,6 +89,30 @@ def check_file_in_work(work_dir, filename):
|
|||||||
mypath = filename
|
mypath = filename
|
||||||
return (mypath, fexists)
|
return (mypath, fexists)
|
||||||
|
|
||||||
|
def write_excel_from_json(anlage:Polylines, outpath:str):
|
||||||
|
wb = Workbook()
|
||||||
|
length_summary = defaultdict(int)
|
||||||
|
|
||||||
|
#Worksheet 1 - Kabellängen
|
||||||
|
ws1 = wb.active
|
||||||
|
ws1.title = "Kabellängen"
|
||||||
|
ws1.append(["Kabel-ID", "Länge aus Json (m)", "Gerundete Länge (m)"])
|
||||||
|
|
||||||
|
for pl in anlage.kabel:
|
||||||
|
length = pl.length /1000 # Umrechnung von mm in m
|
||||||
|
rounded_len = math.ceil(length/10)*10
|
||||||
|
length_summary[rounded_len] +=1
|
||||||
|
ws1.append([pl.id, length, int(rounded_len)])
|
||||||
|
|
||||||
|
# Worksheet 2 - Zusammengefasste Längen
|
||||||
|
ws2 = wb.create_sheet("Längenübersicht")
|
||||||
|
ws2.append(["Gerundete Länge (m)", "Anzahl Kabel"])
|
||||||
|
|
||||||
|
for rlength in sorted(length_summary):
|
||||||
|
ws2.append([int(rlength), length_summary[rlength]])
|
||||||
|
|
||||||
|
wb.save(outpath)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
|||||||
Reference in New Issue
Block a user