[Qgis-user] Fwd: pyqgis dxf

Richard Duivenvoorde rdmailings at duif.net
Wed Feb 25 01:55:27 PST 2015


On 25-02-15 08:05, Alexandre Busquets wrote:
> Hi,
> 
> can somebody help me with load  a dxf file  as a vector layer?
> 
> Is QgsDataSourceURI an option? I tried with this code, but I haven't
> been lucky.
> 
> fitxer="/tmp/prova.dxf"
> uri = QgsDataSourceURI()
> uri.setDatabase(fitxer)
> uri.setDataSource('', 'entities', 'OGR_GEOMETRY',
> "OGR_GEOMETRY='POINT'", 'fid')

iface.addVectorLayer('/tmp/points.dxf', 'mydxflayer', 'ogr')

works for me in the python console

did not try the QGSDataSourceURI-path, but that should also work

(note that depending on you settings and data you will get one or more
dialogs (for crs and/or sub layers)

Regards,

Richard Duivenvoorde




More information about the Qgis-user mailing list