[QGIS-Developer] Loading DXF in QGIS?
Catania, Luke A ERDC-RDE-GRL-VA CIV
Luke.A.Catania at erdc.dren.mil
Tue Oct 3 14:30:22 PDT 2023
I tried the code but it never went through the loop, since it did not find POLYLINES. When I bring the dxf in using QGIS’s Project/Import/Export/Import Layers from DWG/DXF, I see it shows several named layers, but I tried searching on the ones that showed up in the QGIS layer panel of these and nothing was found.
When those imported there were three groups 0, MP.RSRC.CONDAIR, MP.SL and those respectively have layers polylines, hatches, polylines. I tried searching on the group names as well as the lower case polylines layer and the query did not return anything.
From: QGIS-Developer <qgis-developer-bounces at lists.osgeo.org> On Behalf Of Stefan Giese (WhereGroup) via QGIS-Developer
Sent: Tuesday, October 3, 2023 2:59 AM
To: qgis-developer at lists.osgeo.org
Subject: Re: [QGIS-Developer] Loading DXF in QGIS?
Hi,
with ezdxf you can do the job. The following snippet shows how it works:
......
#Reading the dxf and get the modelspace
dwg = ezdxf.readfile(filepath)
msp = dwg.modelspace()
#loop through all Polylines of the DXF
polylines = msp.query('POLYLINE')
for polyline in polylines:
# for example converts a dxf Polyline to a QgsGeometry (Polygon)
points = []
for i, location in enumerate(polyline.points()):
points.append(QgsPointXY(location[0],location[1]))
polygon = QgsGeometry.fromPolygonXY([points])
.....
hope this will be a starting point for you...
Mit freundlichen Grüßen
Stefan Giese
Projektleiter/Consultant
---------------------------------------------
Aufwind durch Wissen!
Web-Seminare und Online-Schulungen
bei der Blockedwww.foss-academy.comBlocked<Blockedhttp://www.foss-academy.comBlocked>
---------------------------------------------
WhereGroup GmbH
Schwimmbadstr. 2
79100 Freiburg
Germany
Tel.: +49 (0)761 / 519 102 - 61
Fax: +49 (0)761 / 519 102 - 11
stefan.giese at wheregroup.com<mailto:stefan.giese at wheregroup.com>
Blockedwww.wheregroup.comBlocked<Blockedhttp://www.wheregroup.comBlocked>
Geschäftsführer:
Olaf Knopp, Peter Stamm
Amtsgericht Bonn, HRB 9885
Am 03.10.2023 um 00:47 schrieb Catania, Luke A ERDC-RDE-GRL-VA CIV via QGIS-Developer:
I have a DXF in both AC1027 and AC1032 format. Original file was a DWG. I converted to DXF using ODA File Converter. I am trying to load in QGIS and dragging and dropping or using the Data Source Manager results in a layer with the name “entities appended to it and nothing shows up. When looking at the properties there is not much there. The layer type is a dataset. I am trying to display all the lines of the dxf.
[cid:image001.png at 01D9F61D.2858E820]
[cid:image002.png at 01D9F61D.2858E820]
[cid:image003.png at 01D9F61D.2858E820]
Now I can use the Project/Import/Export/Import Layers from DWG/DXF to import, but I am looking to do this programmatically in python and I am using ezdxf to assist.
Ideas?
_______________________________________________
QGIS-Developer mailing list
QGIS-Developer at lists.osgeo.org<mailto:QGIS-Developer at lists.osgeo.org>
List info: Blockedhttps://lists.osgeo.org/mailman/listinfo/qgis-developerBlocked
Unsubscribe: Blockedhttps://lists.osgeo.org/mailman/listinfo/qgis-developerBlocked
--
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/qgis-developer/attachments/20231003/3e888add/attachment-0001.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image001.png
Type: image/png
Size: 6904 bytes
Desc: image001.png
URL: <http://lists.osgeo.org/pipermail/qgis-developer/attachments/20231003/3e888add/attachment-0003.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image002.png
Type: image/png
Size: 62713 bytes
Desc: image002.png
URL: <http://lists.osgeo.org/pipermail/qgis-developer/attachments/20231003/3e888add/attachment-0004.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image003.png
Type: image/png
Size: 47885 bytes
Desc: image003.png
URL: <http://lists.osgeo.org/pipermail/qgis-developer/attachments/20231003/3e888add/attachment-0005.png>
More information about the QGIS-Developer
mailing list