Grundlagen für enumerate.bat geschaffen
This commit is contained in:
@@ -0,0 +1,4 @@
|
|||||||
|
@echo off
|
||||||
|
CALL manage_interpreter.bat activate_interpreter
|
||||||
|
python %PROJECT_LIB%\create_numbers.py %*
|
||||||
|
CALL manage_interpreter.bat deactivate_interpreter
|
||||||
@@ -0,0 +1,68 @@
|
|||||||
|
@echo off
|
||||||
|
|
||||||
|
if [%1]==[] goto usage
|
||||||
|
for %%i in ("%~1") do (
|
||||||
|
set "FILENAME=%%~ni"
|
||||||
|
set "EXT=%%~xi"
|
||||||
|
set "DIR=%%~dpi"
|
||||||
|
)
|
||||||
|
call C:\kabellaengen\bin\setenv.bat
|
||||||
|
|
||||||
|
REM echo Dateiname ohne Erweiterung: %FILENAME%
|
||||||
|
REM echo Erweiterung: %EXT%
|
||||||
|
REM echo Verzeichnis: %DIR%
|
||||||
|
REM
|
||||||
|
REM Namen der Zwischenergebnis Dateien
|
||||||
|
set JSON_POS=%FILENAME%_positionsconv.json
|
||||||
|
set JSON_TODRAW=%FILENAME%_todraw.json
|
||||||
|
REM Namen der Ergebnisdateien
|
||||||
|
set ERROR_DOUBLE=%FILENAME%_errors.json
|
||||||
|
set RESULT_TIA=%FILENAME%-*_TIA.xlsx
|
||||||
|
|
||||||
|
if exist "%~dp0_setenv.bat" (
|
||||||
|
echo Lade lokale Umgebungseinstellungen aus _setenv.bat...
|
||||||
|
call "%~dp0_setenv.bat"
|
||||||
|
)
|
||||||
|
REM Zielverzeichnis
|
||||||
|
set TARGET_DIR=%PROJECT_IO_RESULTS%\%FILENAME%
|
||||||
|
mkdir "%TARGET_DIR%"
|
||||||
|
REM lösche alte Fehlermeldungen
|
||||||
|
del "%PROJECT_WORK%\%ERROR_DOUBLE%"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
echo.
|
||||||
|
echo === Fetching Positions ===
|
||||||
|
call getpositions.bat --filename %1 -s -r -w %JSON_POS% -e %ERROR_DOUBLE%
|
||||||
|
if exist "%PROJECT_WORK%\%ERROR_DOUBLE%" (
|
||||||
|
@echo == failed: errors, e.g. duplicate IDs in given layout
|
||||||
|
pause
|
||||||
|
move %PROJECT_WORK%\%ERROR_DOUBLE% %TARGET_DIR%
|
||||||
|
move %PROJECT_WORK%\%JSON_TODRAW% %TARGET_DIR%
|
||||||
|
|
||||||
|
goto :eof
|
||||||
|
)
|
||||||
|
if not exist "%PROJECT_WORK%\%JSON_POS%" (
|
||||||
|
@echo == failed: getpositions
|
||||||
|
pause
|
||||||
|
goto :eof
|
||||||
|
)
|
||||||
|
echo === Creating Excel Files for TIA, WSCAD, .. ===
|
||||||
|
call portalexport.bat --filename %JSON_POS% --outname %FILENAME%
|
||||||
|
if not exist "%PROJECT_WORK%\%RESULT_TIA%" (
|
||||||
|
@echo == failed: creating .xlsx files
|
||||||
|
pause
|
||||||
|
goto :eof
|
||||||
|
)
|
||||||
|
echo move %PROJECT_WORK%\%FILENAME%-* %TARGET_DIR%
|
||||||
|
move %PROJECT_WORK%\%FILENAME%-* %TARGET_DIR%
|
||||||
|
pause
|
||||||
|
goto :eof
|
||||||
|
|
||||||
|
|
||||||
|
:usage
|
||||||
|
@echo Usage: %0 ^<dxfinWorkOrdner.dxf^>
|
||||||
|
exit /B 1
|
||||||
|
goto :eof
|
||||||
|
|
||||||
|
|
||||||
@@ -0,0 +1,111 @@
|
|||||||
|
import argparse
|
||||||
|
import configparser
|
||||||
|
import json
|
||||||
|
import os
|
||||||
|
import re
|
||||||
|
import sys
|
||||||
|
from pathlib import Path
|
||||||
|
|
||||||
|
import ezdxf
|
||||||
|
from ezdxf.addons import iterdxf
|
||||||
|
from shapely.geometry import Point
|
||||||
|
from ezdxf.lldxf.const import DXFStructureError
|
||||||
|
|
||||||
|
from error_collector import ErrorCollector, write_json_file
|
||||||
|
|
||||||
|
|
||||||
|
"""
|
||||||
|
Dieses Programm liest eine dxf Datei und holt sich vom Layer RENAME die Angaben
|
||||||
|
für die Bereiche in der Anlage, welche Motoren, Sensoren und Aktoren welchem
|
||||||
|
Unterverteiler zugeordnet werden müssen. (Attribut KENNZEICHNUNG)
|
||||||
|
Alle Symbol Templates werden entsprechend der Richtungsangaben in DIRECTION nummeriert
|
||||||
|
DIRECTION kann TOP_BOTTOM, BOTTOM_TOP, LEFT_RIGHT oder RIGHT_LEFT sein
|
||||||
|
|
||||||
|
Ein Renamer Symbol enthält z.B. die folgenden Angaben:
|
||||||
|
für POT-RA, POT-MA und POT-UC:
|
||||||
|
|
||||||
|
NAME1=POT-RA@@
|
||||||
|
NAME2=POT-MA@@
|
||||||
|
NAME3=POT-UC@@
|
||||||
|
KENNZEICHNUNG=A01+UC…
|
||||||
|
LAYER_NAME1=ILS_POT-RA
|
||||||
|
LAYER_NAME2=ILS_POT-MA
|
||||||
|
LAYER_NAME3=ILS_POT-UC
|
||||||
|
DIRECTION = LEFT_RIGHT
|
||||||
|
|
||||||
|
für BG, MB:
|
||||||
|
|
||||||
|
NAME1=BG-1@@@
|
||||||
|
NAME2=MB-1@@@
|
||||||
|
NAME3=
|
||||||
|
KENNZEICHNUNG=
|
||||||
|
LAYER_NAME1=ILS_Eingang
|
||||||
|
LAYER_NAME2=ILS_Ausgang
|
||||||
|
LAYER_NAME3=
|
||||||
|
DIRECTION = LEFT_RIGHT
|
||||||
|
|
||||||
|
oder nur zur Nummerierung der MA Symbole
|
||||||
|
NAME=MA-1@@
|
||||||
|
KENNZEICHNUNG=A01+UH00
|
||||||
|
LAYER_NAME=ILS_MOTOR
|
||||||
|
DIRECTION = TOP_BOTTOM/LEFT_RIGHT
|
||||||
|
|
||||||
|
Diese Symbole auf dem RENAMER Layer sind immer in einem Block mit einer Polylinie oder einen REchteck.
|
||||||
|
Alle Sensoren, Motoren, Aktoren etc. innerhalb der zugehörigen Polylinie nehmen an der Nummerierung teil, falls diese das @ Zeichen enthalten, also noch ein Template sind.
|
||||||
|
|
||||||
|
"""
|
||||||
|
|
||||||
|
|
||||||
|
def check_file_in_work(work_dir: Path, filename: Path) -> tuple[Path, bool]:
|
||||||
|
fexists = True
|
||||||
|
if not filename.exists():
|
||||||
|
mypath = work_dir.joinpath(filename)
|
||||||
|
ex = mypath.exists()
|
||||||
|
if not mypath.exists():
|
||||||
|
fexists = False
|
||||||
|
else:
|
||||||
|
mypath = filename
|
||||||
|
return mypath, fexists
|
||||||
|
|
||||||
|
def check_environment_var(env_str: str) -> Path:
|
||||||
|
out_path = os.environ.get(env_str)
|
||||||
|
if out_path:
|
||||||
|
return Path(out_path)
|
||||||
|
else:
|
||||||
|
print(f"Umgebungsvariable {env_str} ist nicht gesetzt oder leer.")
|
||||||
|
exit()
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
parser = argparse.ArgumentParser(description='fetches the x/y positions from a dxf file', prog='getpositions')
|
||||||
|
parser.add_argument('-f', '--filename', action='store', required=True, default="ST_6300_Steuerungstestlayout1_neueBloecke.dwg", help='which file should be fetched', metavar='myfile.dxf')
|
||||||
|
parser.add_argument('-w', '--write', action='store', help='write results into a json file')
|
||||||
|
|
||||||
|
args = parser.parse_args()
|
||||||
|
|
||||||
|
out_dir = check_environment_var('PROJECT_DATA')
|
||||||
|
work_dir = check_environment_var('PROJECT_WORK')
|
||||||
|
config_dir = check_environment_var("PROJECT_CFG")
|
||||||
|
|
||||||
|
filename = Path(args.filename)
|
||||||
|
if not filename.suffix == ".dxf":
|
||||||
|
print("only available for .dxf files")
|
||||||
|
exit()
|
||||||
|
|
||||||
|
(dxf_path, dexists) = check_file_in_work(work_dir, filename)
|
||||||
|
if dexists == False:
|
||||||
|
print("no such file ")
|
||||||
|
parser.print_help()
|
||||||
|
exit()
|
||||||
|
|
||||||
|
if dxf_is_binary(dxf_path): # Wenn dxf eine binary ist, dann komplett parsen und modelspace anlegen
|
||||||
|
print("Given .dxf-file is binary dxf. Proceeding to read file. Watch RAM-usage.")
|
||||||
|
doc = get_dxf_file(dxf_path)
|
||||||
|
msp = doc.modelspace()
|
||||||
|
use_iter = False
|
||||||
|
else:
|
||||||
|
print("Given .dxf-file is ASCII-dxf. Proceeding to use iterative functions. Process may take longer.")
|
||||||
|
use_iter = True
|
||||||
|
|
||||||
|
|
||||||
|
else:
|
||||||
|
parser.print_help()
|
||||||
Vendored
BIN
Binary file not shown.
Reference in New Issue
Block a user