Search code examples
androidautocadcaddxf

Android: Autocad Coordinates are too large


I'm working on Autocad files reader for android , now I Only read DXF files using Kabeja library and it works great but when i draw simple shape in Autocad and try to draw it on Android it doesn't appear when i look to Autocad coordinates i find them are too large I have already did a lot of search to find out any solution and one i tried is to read

EXTMIN and EXTMAX

header values but they return {30=0.0, 20=1015.620062425179, 10=1624.318980044965} for EXTMIN and {30=0.0, 20=2134.42060268589, 10=3716.108222970341} for EXTMAX

this is my code

DXFHeader dxfHeader = dxfDoc.getDXFHeader();
DXFVariable dxfVariableMin = dxfHeader.getVariable("$EXTMIN");
DXFVariable dxfVariableMax = dxfHeader.getVariable("$EXTMAX");

i don't know how to use these values to make my shapes be drawn correctly


Solution

  • EXTMIN and EXTMAX define the area of the dxf drawing that contains geometry (entities).

    When displaying a dxf file, you would use the EXTMIN values as an offset.

    In your example, the lower-left corner of dxf file area that contains geometry is:

    1624.318980044965, 1015.620062425179
    

    while the upper-right corner is:

    3716.108222970341, 2134.42060268589
    

    This means that your effective canvas size is actually 2091 wide by 1118 tall.

    If you had an entity, like a circle, whose x,y center coordinates were 2000,1500; you could then subtract the EXTMIN coords and display the circle at 375.68, 484.38

    As long as you subtract the EXTMIN coords from all your entities's x and y coords (10 and 20 group codes) you will be able to display a smaller area that just includes the area that contains geometry.