Yes, just load your DEM and the base DWG file, then use the File->Export Vector->Export DXF menu command and check the box to create 3D features using loaded elevation data. You should then get 3D features in the exported DXF file using the elevation values from the loaded DEM grid file.
I've done that process (load my DEM and base DWG file, then use the File->Export Vector->Export DXF menu command and check the box to create 3D features using loaded elevation data), but the result is a dxf file whose the features have z = 0
Do I have to make more steps before the export to asociate z coordinates?
Could you try the process whith the example data that I attached in my original post?
I took a look and discovered the problem. Your original DWG file already had elevation values associated with them, they just all had a value of 0. What you need to do is select all of your features from the DWG file and edit them, then remove the ELEVATION attribute, then do the export.
I have attached the resulting 3D DXF file when I do this.