erste Fassung von drawdxf dazu. Temporäre Tilde Dateien rausgeschmissen

This commit is contained in:
2025-05-07 12:52:49 +02:00
parent 58195eebfa
commit 27c2984b7a
4 changed files with 59 additions and 35 deletions
+15 -3
View File
@@ -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"
]
}
]
}
Binary file not shown.
+44 -11
View File
@@ -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()
-21
View File
@@ -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