<div dir="ltr"><div><div>Hi Ricard,</div><div><br></div><div>thanks for your help, but this is not a valid option for me. I need  load the layer directly, without the  "Select vector layers to add" dialog.</div></div><div><br></div><div><br></div><div><br></div><div><br></div><div><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">2015-02-25 10:55 GMT+01:00 Richard Duivenvoorde <span dir="ltr"><<a href="mailto:rdmailings@duif.net" target="_blank">rdmailings@duif.net</a>></span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">On 25-02-15 08:05, Alexandre Busquets wrote:<br>
> Hi,<br>
><br>
> can somebody help me with load  a dxf file  as a vector layer?<br>
><br>
> Is QgsDataSourceURI an option? I tried with this code, but I haven't<br>
> been lucky.<br>
><br>
> fitxer="/tmp/prova.dxf"<br>
> uri = QgsDataSourceURI()<br>
> uri.setDatabase(fitxer)<br>
> uri.setDataSource('', 'entities', 'OGR_GEOMETRY',<br>
> "OGR_GEOMETRY='POINT'", 'fid')<br>
<br>
</span>iface.addVectorLayer('/tmp/points.dxf', 'mydxflayer', 'ogr')<br>
<br>
works for me in the python console<br>
<br>
did not try the QGSDataSourceURI-path, but that should also work<br>
<br>
(note that depending on you settings and data you will get one or more<br>
dialogs (for crs and/or sub layers)<br>
<br>
Regards,<br>
<br>
Richard Duivenvoorde<br>
<br>
_______________________________________________<br>
Qgis-user mailing list<br>
<a href="mailto:Qgis-user@lists.osgeo.org">Qgis-user@lists.osgeo.org</a><br>
<a href="http://lists.osgeo.org/mailman/listinfo/qgis-user" target="_blank">http://lists.osgeo.org/mailman/listinfo/qgis-user</a><br>
</blockquote></div><br></div>