<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="Generator" content="Microsoft Word 15 (filtered medium)">
<!--[if !mso]><style>v\:* {behavior:url(#default#VML);}
o\:* {behavior:url(#default#VML);}
w\:* {behavior:url(#default#VML);}
.shape {behavior:url(#default#VML);}
</style><![endif]--><style><!--
/* Font Definitions */
@font-face
        {font-family:"Cambria Math";
        panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
        {font-family:Consolas;
        panose-1:2 11 6 9 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0in;
        font-size:11.0pt;
        font-family:"Calibri",sans-serif;}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
pre
        {mso-style-priority:99;
        mso-style-link:"HTML Preformatted Char";
        margin:0in;
        font-size:10.0pt;
        font-family:"Courier New";}
span.HTMLPreformattedChar
        {mso-style-name:"HTML Preformatted Char";
        mso-style-priority:99;
        mso-style-link:"HTML Preformatted";
        font-family:Consolas;}
span.EmailStyle21
        {mso-style-type:personal-reply;
        font-family:"Calibri",sans-serif;
        color:windowtext;}
.MsoChpDefault
        {mso-style-type:export-only;
        font-size:10.0pt;}
@page WordSection1
        {size:8.5in 11.0in;
        margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
        {page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
</head>
<body lang="EN-US" link="blue" vlink="purple" style="word-wrap:break-word">
<div class="WordSection1">
<p class="MsoNormal">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.<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">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.<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<div>
<div style="border:none;border-top:solid #E1E1E1 1.0pt;padding:3.0pt 0in 0in 0in">
<p class="MsoNormal"><b>From:</b> QGIS-Developer <qgis-developer-bounces@lists.osgeo.org>
<b>On Behalf Of </b>Stefan Giese (WhereGroup) via QGIS-Developer<br>
<b>Sent:</b> Tuesday, October 3, 2023 2:59 AM<br>
<b>To:</b> qgis-developer@lists.osgeo.org<br>
<b>Subject:</b> Re: [QGIS-Developer] Loading DXF in QGIS?<o:p></o:p></p>
</div>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
<p>Hi,<o:p></o:p></p>
<p>with ezdxf you can do the job. The following snippet shows how it works:<o:p></o:p></p>
<p><i>......    </i><o:p></o:p></p>
<p><i>#Reading the dxf and get the modelspace<br>
    dwg = ezdxf.readfile(filepath)<br>
    msp = dwg.modelspace()<br>
<br>
    #loop through all Polylines of the DXF<br>
    polylines = msp.query('POLYLINE')<br>
    for polyline in polylines:</i><o:p></o:p></p>
<p><i>       # for example converts a dxf Polyline to a QgsGeometry (Polygon)<br>
       points = []<br>
       for i, location in enumerate(polyline.points()):<br>
           points.append(QgsPointXY(location[0],location[1]))<br>
      polygon = QgsGeometry.fromPolygonXY([points])</i><o:p></o:p></p>
<p><i>.....</i><o:p></o:p></p>
<p>hope this will be a starting point for you...<o:p></o:p></p>
<pre>Mit freundlichen Grüßen<o:p></o:p></pre>
<pre>Stefan Giese<o:p></o:p></pre>
<pre>Projektleiter/Consultant<o:p></o:p></pre>
<pre>---------------------------------------------<o:p></o:p></pre>
<pre>Aufwind durch Wissen!<o:p></o:p></pre>
<pre>Web-Seminare und Online-Schulungen<o:p></o:p></pre>
<pre>bei der <a href="Blockedhttp://www.foss-academy.comBlocked">Blockedwww.foss-academy.comBlocked</a><o:p></o:p></pre>
<pre>---------------------------------------------<o:p></o:p></pre>
<pre>WhereGroup GmbH<o:p></o:p></pre>
<pre>Schwimmbadstr. 2<o:p></o:p></pre>
<pre>79100 Freiburg<o:p></o:p></pre>
<pre>Germany<o:p></o:p></pre>
<pre><o:p> </o:p></pre>
<pre>Tel.: +49 (0)761 / 519 102 - 61<o:p></o:p></pre>
<pre>Fax: +49 (0)761 / 519 102 - 11<o:p></o:p></pre>
<pre><o:p> </o:p></pre>
<pre><a href="mailto:stefan.giese@wheregroup.com">stefan.giese@wheregroup.com</a><o:p></o:p></pre>
<pre><a href="Blockedhttp://www.wheregroup.comBlocked">Blockedwww.wheregroup.comBlocked</a><o:p></o:p></pre>
<pre>Geschäftsführer:<o:p></o:p></pre>
<pre>Olaf Knopp, Peter Stamm<o:p></o:p></pre>
<pre>Amtsgericht Bonn, HRB 9885<o:p></o:p></pre>
<div>
<p class="MsoNormal">Am 03.10.2023 um 00:47 schrieb Catania, Luke A ERDC-RDE-GRL-VA CIV via QGIS-Developer:<o:p></o:p></p>
</div>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal">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.<o:p></o:p></p>
<p class="MsoNormal"> <o:p></o:p></p>
<p class="MsoNormal"><img border="0" width="513" height="114" style="width:5.3416in;height:1.1916in" id="Picture_x0020_3" src="cid:image001.png@01D9F61D.2858E820"><o:p></o:p></p>
<p class="MsoNormal"> <o:p></o:p></p>
<p class="MsoNormal"><img border="0" width="705" height="382" style="width:7.3416in;height:3.975in" id="Picture_x0020_1" src="cid:image002.png@01D9F61D.2858E820"><o:p></o:p></p>
<p class="MsoNormal"> <o:p></o:p></p>
<p class="MsoNormal"><img border="0" width="903" height="335" style="width:9.4083in;height:3.4916in" id="Picture_x0020_2" src="cid:image003.png@01D9F61D.2858E820"><o:p></o:p></p>
<p class="MsoNormal"> <o:p></o:p></p>
<p class="MsoNormal">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.<o:p></o:p></p>
<p class="MsoNormal"> <o:p></o:p></p>
<p class="MsoNormal">Ideas?<o:p></o:p></p>
<p class="MsoNormal"> <o:p></o:p></p>
<p class="MsoNormal"> <o:p></o:p></p>
<p class="MsoNormal"> <o:p></o:p></p>
<p class="MsoNormal"> <o:p></o:p></p>
<p class="MsoNormal"> <o:p></o:p></p>
<p class="MsoNormal"><br>
<br>
<o:p></o:p></p>
<pre>_______________________________________________<o:p></o:p></pre>
<pre>QGIS-Developer mailing list<o:p></o:p></pre>
<pre><a href="mailto:QGIS-Developer@lists.osgeo.org">QGIS-Developer@lists.osgeo.org</a><o:p></o:p></pre>
<pre>List info: <a href="Blockedhttps://lists.osgeo.org/mailman/listinfo/qgis-developerBlocked">Blockedhttps://lists.osgeo.org/mailman/listinfo/qgis-developerBlocked</a><o:p></o:p></pre>
<pre>Unsubscribe: <a href="Blockedhttps://lists.osgeo.org/mailman/listinfo/qgis-developerBlocked">Blockedhttps://lists.osgeo.org/mailman/listinfo/qgis-developerBlocked</a><o:p></o:p></pre>
</blockquote>
<pre>-- <o:p></o:p></pre>
</div>
</body>
</html>