Exporting contour lines from CAD to GIS

If it is 3D DXF, follow the steps:

  1. import the dxf in QGIS (DRAG & DROP or CTRL + V);
  2. save as vectors (as the right mouse button);
  3. add new field Z (integer);
  4. Browser Panel to create a new database spatialite;
  5. DBManager to import the shape in the newly created database;
  6. run the update query;

step 1 picture 1

step 2 picure 2 picture 3

step 3 - add new field Z picture 4

step 5 -DB Manager picture 5

picture 6

picture 7

step 6 - query picture 8

picture 9

picture 10


@pigreco's answer should work.

But here a simpler solution without the spatialite process (step 1 to 2 are the same).

  1. Load your .dxf and export (save as...) as shapefile (or spatialite / postgis).

  2. On the new layer, use the Field Calculator (accessible from the main toolbar or from the attribute table).

    enter image description here

  3. Setup the new column (name and type, virtual or not depending on your needs) and use the expression :

    z(point_n($geometry, 1))

enter image description here

As @pigreco said, your dxf needs to be 3D.