7

I want to convert a DXF with python/ogr2ogr. Unfortunately QGIS 2.99 always asks for the CRS.

QSettings().value('/Projections/defaultBehavior')
'useGlobal'
QSettings().value('/Projections/layerDefaultCrs')
'EPSG:25833'

processing.run('gdal:convertformat',{'INPUT':'d:/tar/mytest.dxf','OPTIONS':'','OUTPUT': 'c:/../x.shp'})

Without the processing-plugin the following code also produce a CRS Window

from processing.tools import dataobjects
parameters={'INPUT':'d:/tar/mytest.dxf','OPTIONS':'','OUTPUT': 'c:/../x.shp'}
context=dataobjects.createContext(None)
alg = QgsApplication.processingRegistry().createAlgorithmById('gdal:convertformat')
alg.checkParameterValues(parameters, context)

Is there a way to prevent the "Coordinate Reference System Selector" query/window?

I need this code for my plugin "Another DXF Importer / DXF2Shape Converter". This command is called 3-5 times per DXF. If there are 5 DXF-s, the dialog window appears 15-25 times. The query of the CRS is absolutely superfluous, since no transformation should take place and also no projection file must be written.

The code for QGIS 2.xx

processing.runalg('gdalogr:convertformat','d:/tar/mytest.dxf‌​',0,None,'d:/tar/xx.‌​shp')

works without Problems (without window)

  • 1
    I'm not answering your question. But side note, I think in QGIS 3, you should use QgsSettings instead of QSettings. – etrimaille Jan 15 '18 at 18:59
1

for disable this dialog using QGIS 3 only need this,

settings = QSettings()
settings.setValue('/Projections/defaultBehavior', '')

and if you want disable and enable after execute your code,

prjSetting3= settings.value('/Projections/defaultBehavior')
settings.setValue('/Projections/defaultBehavior', '')

......

settings.setValue('/Projections/defaultBehavior', prjSetting3)
  • Just a comment to note this should work on QGIS 2 also. – Alex Leith Jan 17 '18 at 21:15
  • No, that does not work. Also with this code comes the CRS window settings = QSettings() settings.setValue('/Projections/defaultBehavior', '') processing.run('gdal:convertformat',{'INPUT':'d:/tar/mytest.dxf','OPTIONS':'','OUTPUT': 'c:/../x.shp'}) – Mike Jan 18 '18 at 8:26
  • Oops!sorry!this code disable the load crs dialog but not the input dialog – Fran Raga Jan 18 '18 at 10:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.