erste Fassung von drawdxf dazu. Temporäre Tilde Dateien rausgeschmissen
This commit is contained in:
Vendored
+15
-3
@@ -34,7 +34,7 @@
|
|||||||
"-d",
|
"-d",
|
||||||
"-r",
|
"-r",
|
||||||
"-c"
|
"-c"
|
||||||
],
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "use easy.dxf, nur Pritsche",
|
"name": "use easy.dxf, nur Pritsche",
|
||||||
@@ -48,7 +48,7 @@
|
|||||||
"easy.dxf",
|
"easy.dxf",
|
||||||
"-r",
|
"-r",
|
||||||
"-c"
|
"-c"
|
||||||
],
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "use Steuerungstestlayout",
|
"name": "use Steuerungstestlayout",
|
||||||
@@ -63,7 +63,19 @@
|
|||||||
"-s",
|
"-s",
|
||||||
"-d",
|
"-d",
|
||||||
"-r"
|
"-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
@@ -1,8 +1,23 @@
|
|||||||
|
import argparse
|
||||||
import ezdxf
|
import ezdxf
|
||||||
import random # needed for random placing points
|
import random # needed for random placing points
|
||||||
from ezdxf.enums import TextEntityAlignment
|
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():
|
def get_random_point():
|
||||||
"""Returns random x, y coordinates."""
|
"""Returns random x, y coordinates."""
|
||||||
x = random.randint(-100, 100)
|
x = random.randint(-100, 100)
|
||||||
@@ -56,18 +71,36 @@ def add_polyline(msp):
|
|||||||
points = [(0, 0), (3, 0), (6, 3), (6, 6)]
|
points = [(0, 0), (3, 0), (6, 3), (6, 6)]
|
||||||
msp.add_lwpolyline(points)
|
msp.add_lwpolyline(points)
|
||||||
|
|
||||||
# Create a new drawing in the DXF format of AutoCAD 2010
|
def new_dxf(path):
|
||||||
doc = ezdxf.new('R2018', setup=True)
|
|
||||||
|
|
||||||
# add new entities to the modelspace
|
# Create a new drawing in the DXF format of AutoCAD 2010
|
||||||
msp = doc.modelspace()
|
doc = ezdxf.new('R2018', setup=True)
|
||||||
# # Beispiel für Text und Polyline
|
|
||||||
# add_text(msp)
|
|
||||||
# add_polyline(msp)
|
|
||||||
|
|
||||||
# Beispiel für Block
|
# add new entities to the modelspace
|
||||||
create_block(doc)
|
msp = doc.modelspace()
|
||||||
create_points(msp)
|
# # 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()
|
||||||
|
|||||||
@@ -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
|
|
||||||
Reference in New Issue
Block a user