1

I found what seems to answer my question by @xunilk in this closed post: Filling polygons with points or polygons using PyQGIS?

I follow the example of @xunilk with some modifications to adapt to QGIS version 3.4. But at the end of the python scipt I have this error message: "NameError: name 'QgsMapLayerRegistry' is not defined".

In the autocompletion of the python console, there is no QgsMapLayerRegistry function.

4
  • Welcome to GIS SE! We're a little different from other sites. We're a Q&A site, not a discussion forum. For questions that involve code we ask that you show us where you are stuck with your own code by including a code snippet in your question. There is an edit button beneath your question which will enable you to do that and a {} button that enables you to format any highlighted code nicely. Please check out our short tour for more about how the site works. Thanks.
    – PolyGeo
    Oct 29 '18 at 23:36
  • In the QGIS 3 API, QgsMapLayerRegistry has been replaced by QgsProject. So to add your layer you need to do: QgsProject.instance().addMapLayer(mem_layer). You said you made some modifications to adapt to QGIS3, but you should be aware there are numerous API breaking changes in version 3. If you have any other issues you should post your code so we can help you properly.
    – Ben W
    Oct 30 '18 at 2:05
  • You should post a code snippet in any case so that the question can be re-opened and answered properly to help others in the future.
    – Ben W
    Oct 30 '18 at 2:23
  • Thank you Ben W, you have answered my question. I'm new to QGIS and what I want is to convert a DXF inner shape to points for my other not GIS project. Nov 10 '18 at 10:27

Browse other questions tagged or ask your own question.