diff --git a/.vscode/launch.json b/.vscode/launch.json index c4a5083..ac9d40e 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -34,7 +34,7 @@ "-d", "-r", "-c" - ], + ] }, { "name": "use easy.dxf, nur Pritsche", @@ -48,7 +48,7 @@ "easy.dxf", "-r", "-c" - ], + ] }, { "name": "use Steuerungstestlayout", @@ -63,7 +63,19 @@ "-s", "-d", "-r" - ], + ] + }, + { + "name": "draw cable dxf from easy.dxf", + "type": "debugpy", + "request": "launch", + "program": "${file}", + "console": "integratedTerminal", + "justMyCode": true, + "args": [ + "--filename", + "easy.dxf" + ] } ] } \ No newline at end of file diff --git a/lib/.requirements.txt.un~ b/lib/.requirements.txt.un~ deleted file mode 100644 index 308745e..0000000 Binary files a/lib/.requirements.txt.un~ and /dev/null differ diff --git a/lib/drawdxf.py b/lib/drawdxf.py index 6577755..cbbe423 100644 --- a/lib/drawdxf.py +++ b/lib/drawdxf.py @@ -1,8 +1,23 @@ +import argparse import ezdxf import random # needed for random placing points from ezdxf.enums import TextEntityAlignment +import os.path +from dataclasses import dataclass, asdict, fields +from dacite import from_dict +from typing import List +@dataclass +class Point: + x: float + y: float + +@dataclass +class Polyline: + id: str + punkte: List[Point] + def get_random_point(): """Returns random x, y coordinates.""" x = random.randint(-100, 100) @@ -56,18 +71,36 @@ def add_polyline(msp): points = [(0, 0), (3, 0), (6, 3), (6, 6)] msp.add_lwpolyline(points) -# Create a new drawing in the DXF format of AutoCAD 2010 -doc = ezdxf.new('R2018', setup=True) +def new_dxf(path): + -# add new entities to the modelspace -msp = doc.modelspace() -# # Beispiel für Text und Polyline -# add_text(msp) -# add_polyline(msp) + # Create a new drawing in the DXF format of AutoCAD 2010 + doc = ezdxf.new('R2018', setup=True) -# Beispiel für Block -create_block(doc) -create_points(msp) + # add new entities to the modelspace + msp = doc.modelspace() + # # Beispiel für Text und Polyline + # add_text(msp) + # add_polyline(msp) -doc.saveas("lwpolyline.dxf") + # Beispiel für Block + create_block(doc) + create_points(msp) + doc.saveas(path) + + +if __name__ == '__main__': + parser = argparse.ArgumentParser(description='draws a dxf file with the given cable coordinates', prog='drawdxf') + parser.add_argument('-f', '--filename', action='store', required=True, default="easy.dwg", help='which file should be fetched', metavar='myfile.dwg') + + args = parser.parse_args() + + work_dir = os.environ.get('PROJECT_WORK') + filename = os.fspath(args.filename) + path = os.path.join(work_dir, filename + '_cable.dxf') + + if args.filename: + res_pos = new_dxf(filename) + else: + parser.print_help() diff --git a/lib/requirements.txt~ b/lib/requirements.txt~ deleted file mode 100644 index a0ba30d..0000000 --- a/lib/requirements.txt~ +++ /dev/null @@ -1,21 +0,0 @@ -contourpy==1.3.1 -cycler==0.12.1 -et-xmlfile==1.1.0 -ezdxf==1.4.0 -fonttools==4.57.0 -kiwisolver==1.4.8 -numpy==1.26.1 -openpyxl==3.1.2 -packaging==24.2 -pillow==11.1.0 -PyMuPDF==1.25.5 -pyparsing==3.2.3 -PySide6==6.9.0 -PySide6_Addons==6.9.0 -PySide6_Essentials==6.9.0 -python-dateutil==2.8.2 -pytz==2023.3.post1 -shiboken6==6.9.0 -six==1.16.0 -typing_extensions==4.13.1 -tzdata==2023.3