1

I want to import simple blocks (rectangles with a "Value", that is a text string) from a DXF to QGIS. I want to keep that value so it shows up as an attribute in the corresponding layer in QGIS. I have tried Importing from the File-menu, and importing as a single vector layer.

I have tried importing from DWG, different versions, and DXF, different versions. The closest I come is that QGIS create a point that origins from a blocks text components insertion (text placement) point. But I want this text to be an attribute in the imported block object (a point in QGIS) instead.

enter image description here

7
  • Try exporting the data from ACAD using the spatial manager to create a .shp.
    – Erik
    Commented Jun 11, 2020 at 11:28
  • 1
    Try AnotherDXFImporter Plugin: plugins.qgis.org/plugins/AnotherDXF2Shape Commented Jun 11, 2020 at 15:07
  • @Erik I tried the spatial manager but the result is the same - it doesn't seem to be able to read the "Value" field that I want.
    – Andreas
    Commented Jun 12, 2020 at 12:35
  • @HeikkiVesantoI tried this before, the same result unfortunately.
    – Andreas
    Commented Jun 12, 2020 at 12:36
  • @Erik Update: I actually found the info embedded in a long text string in the field "ExtendedEntity", perhaps I can extract that using Excel. I will try it, thanks.
    – Andreas
    Commented Jun 12, 2020 at 12:43

1 Answer 1

1

I wrote a small gawk script to collect attributes from DXF file into a CSV file, what you can load as delimited text (Point) layer into QGIS. See: https://github.com/zsiki/dxf_utils (dxf_attr2csv.awk).

Simple docs are available on GitHub.

4
  • Wow, that worked exactly as I wanted. Thank you very much!
    – Andreas
    Commented Jun 12, 2020 at 12:59
  • It seems that the script creates the coordinates from the insertion point of the text included in the block, rather than get the coordinates of the center point of the block symbol, is that correct? I guess there is no way to adjust this?
    – Andreas
    Commented Jun 23, 2020 at 7:18
  • You are right, the position of the attribute is sent to the output, not the insertion point of the block. You should move two lines: if (last == " 10") { x = $0; } if (last == " 20") { y = $0; } into the previous conditional block. I uploaded the code variant to github as dxf2atr.awk
    – Zoltan
    Commented Jun 23, 2020 at 19:20
  • It works just as I hoped, thank you very much for your help and quick response!
    – Andreas
    Commented Jun 25, 2020 at 9:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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