Lesen Sie DXF mit Python

Es scheint, dass Sie DXF mit Python mit dxfgrabber lesen können pip install dxfgrabber

Erstellen Sie eine entsprechende DXF-Datei mit kostenlosem 2D-CAD jw_cad und lesen Sie sie.

dxf.py


import dxfgrabber

dxf = dxfgrabber.readfile("test.dxf")
#Header
print(dxf.header)
#{'$ACADVER': 'AC1009', '$DWGCODEPAGE': 'ANSI_1252', '$INSBASE': (0.0, 0.0, 0.0), '$EXTMIN': (0.0, 0.0), '$EXTMAX': (841.0, 594.0), '$LIMMIN': (0.0, 0.0), '$LIMMAX': (841.0, 594.0), '$LTSCALE': 1.0}

#Grafisches Element
# print(vars(dxf.entities))
cirs = [e for e in dxf.entities if e.dxftype == 'CIRCLE']
lines = [e for e in dxf.entities if e.dxftype == 'LINE']

#Kreis
print(vars(cirs[0]))
# {'dxftype': 'CIRCLE', 'handle': None, 'owner': None, 'paperspace': None, 'layer': '_0-0_', 'linetype': 'CONTINUOUS', 'thickness': 0.0, 'extrusion': (0.0, 0.0, 1.0), 'ltscale': 1.0, 'line_weight': 0, 'invisible': 0, 'color': 7, 'true_color': None, 'transparency': None, 'shadow_mode': None, 'layout_tab_name': None, 'center': (94.41901840490794, 356.85030674846627), 'radius': 16.151818630112004}
#Mittelpunkt ist der Mittelpunkt des Kreises x, y
#Radius ist der Kreisradius
#Linientyp ist der Linientyp

#Gerade Linie
print(vars(lines[0]))
#{'dxftype': 'LINE', 'handle': None, 'owner': None, 'paperspace': None, 'layer': '_0-0_', 'linetype': 'CONTINUOUS', 'thickness': 0.0, 'extrusion': None, 'ltscale': 1.0, 'line_weight': 0, 'invisible': 0, 'color': 7, 'true_color': None, 'transparency': None, 'shadow_mode': None, 'layout_tab_name': None, 'start': (386.4472392638037, 316.28711656441715), 'end': (386.4472392638037, 522.9865030674847)}
#Start ist der Startpunkt x,y, Ende ist der Endpunkt x,y
#Linientyp ist der Linientyp

#Zeilentypenliste(jw_cad)
print(vars(dxf.linetypes))
#{'_table_entries': {'CONTINUOUS': <dxfgrabber.linetypes.Linetype object at 0x000002B43A5796A0>, 'DASHED1': <dxfgrabber.linetypes.Linetype object at 0x000002B43A5796D8>, 'DASHED2': <dxfgrabber.linetypes.Linetype object at 0x000002B43A579710>, 'DASHED3': <dxfgrabber.linetypes.Linetype object at 0x000002B43A579748>, 'CENTER1': <dxfgrabber.linetypes.Linetype object at ...

Referenz https://qiita.com/ackermanrf128/items/d9275a7d077c1dff3ec7

Recommended Posts

Lesen Sie DXF mit Python
Lesen Sie Eulers Formel in Python
Lesen Sie XML mit dem in Python angegebenen Namespace
Lesen Sie Outlook-E-Mails mit Python
Lesen Sie die Fortran-Ausgabe mit Python
Lesen Sie die Protokollpufferdaten mit Python3
Lesen Sie PNG-Chunks in Python (Klassenausgabe)
Lesen Sie Dateien parallel zu Python
Erstellen und lesen Sie Messagepacks in Python
Quadtree in Python --2
Python in der Optimierung
Metaprogrammierung mit Python
Python 3.3 mit Anaconda
Geokodierung in Python
SendKeys in Python
Metaanalyse in Python
Unittest in Python
Epoche in Python
Zwietracht in Python
Deutsch in Python
DCI in Python
Quicksort in Python
nCr in Python
N-Gramm in Python
Programmieren mit Python
Plink in Python
Konstante in Python
FizzBuzz in Python
SQLite in Python
Schritt AIC in Python
LINE-Bot [0] in Python
CSV in Python
Reverse Assembler mit Python
Reflexion in Python
Konstante in Python
nCr in Python.
Format in Python
Scons in Python 3
Puyopuyo in Python
Python in Virtualenv
PPAP in Python
Quad-Tree in Python
Reflexion in Python
Chemie mit Python
Hashbar in Python
DirectLiNGAM in Python
LiNGAM in Python
In Python reduzieren
[Python] Daten lesen
In Python flach drücken
Lesen Sie die Datei Zeile für Zeile mit Python
Lesen Sie die Datei Zeile für Zeile mit Python
Lesen und schreiben Sie JSON-Dateien mit Python
[Python] Lesen Sie die angegebene Zeile in der Datei
Lesen von Zeichen in Bildern mit Python OCR
Sortierte Liste in Python
Täglicher AtCoder # 36 mit Python
AtCoder # 2 jeden Tag mit Python