title: How to find dimensions of a shape in DXF in python?
body: <p>I am trying to get the shape's dimensions, from dxf files. I tried looking into dxfgrabber and ezdxf libraries, I took the <strong>lowest and highest points</strong> to get the dimensions, but the result was wrong.
  Using dxfgrabber:</p>
  
  <pre><code>import dxfgrabber
  import numpy as np
  import sys
  
  dxf = dxfgrabber.readfile(sys.argv[1])
  shapes = dxf.entities.get_entities()
  minX, maxX, minY, maxY = 999999,0,999999,0
  for shape in shapes:
      print('dxftype', shape.dxftype)
      if shape.dxftype == 'LINE':
          x, y = shape.start[0], shape.start[1]
          if x &lt; minX:
              minX = x
          if y &lt; minY:
              minY = y
          if x &gt;= maxX:
              maxX = x
          if y &gt;= maxY:
              maxY = y
          x, y = shape.end[0], shape.end[1]
          if x &lt; minX:
              minX = x
          if y &lt; minY:
              minY = y
          if x &gt;= maxX:
              maxX = x
          if y &gt;= maxY:
              maxY = y
      if shape.dxftype == 'ARC':
          x, y = shape.center[0], shape.center[1]
          if x &lt; minX:
              minX = x
          if y &lt; minY:
              minY = y
          if x &gt;= maxX:
              maxX = x
          if y &gt;= maxY:
              maxY = y
  print('minX', minX, 'minY', minY)
  print('maxX', maxX, 'maxY', maxY)
  print('x1', 0, 'y1', 0)
  print('x2', maxX-minX, 'y2', maxY-minY)
  </code></pre>
  
  <p>Using ezdxf:</p>
  
  <pre><code>modelspace = dwg.modelspace()
  for e in modelspace:
       if e.dxftype() == 'LINE':
           print("start point: ",  e.dxf.start)
           print("end point: ",  e.dxf.end)
       if e.dxftype() == 'ARC':
           print("ARC on layer: ", e.dxf.layer)
           print("center point ", e.dxf.center)
  </code></pre>
  
  <p>And manually took the minX minY maxX maxY.<br>
  Is there any way of calculating, or any existing libraries to get the dimensions ?</p>