Search code examples
pythonezdxf

ezdxf convert WCS to DCS


I am trying to parse .dxf files and I am trying to figure out how to get the dimensions of the actual page (which I got using doc.layouts.active_layout().get_paper_limits() ) and where the page's entities are in relation to each other and the page itself. I would not be editing the file at any point, only extracting information from it.

For example, I would like to know that Text Entity A is at the bottom right corner of the page and that Text Entity B is to the left of Text Entity A. I found out how to convert everything to WCS, but I believe that DCS makes more sense for my problem. Any unified coordinate system would work if they are all on the same scale, including the size of the page, however, I am only seeing that DCS would work.

I have been combing through the ezdxf documentation about the coordinate systems, but I have been unable to locate if there is a way to convert WCS to DCS. If there is a way to do this, or if there is another way to approach this problem that I am missing, please let me know! Thanks for your kind answers.


Solution

  • Nevermind, I figured it out. I can use the WCS for entities that I got from following the instructions in the documentation and I can get the limits of the page in WCS using:

    doc = ezdxf.readfile("some_doc.dxf")
    top_right = doc.header["$EXTMAX"]
    bottom_left = doc.header["$EXTMIN"]
    

    So no need to convert into DCS after all.