@Gaganpatel hi,
your request may look very simple to accomplish but it's totally beyond that but i managed to get over all the difficulties and i hope this will be your answer.
attached fdall.zip file contain fdall.vlx lisp file to be load in autocad.
cause you did not provide any explanation on what your are doing so i called the rectangle lines "Feature" and the lisp is Feature Dimension All.
it's important that you read this all so you will understand under what terms it works:
limitation:
the feature (the lines) must form a straight rectangle and must be aligned to wcs
dimension style:
the fdall.vlx uses the current dimstyle. if the dimstyle is not well defined, you will get ugly result.
running lisp:
after loading it, you will be prompt to select objects: select the feature (4 lines) and all the circle blocks in one shot.
program process:
it start by checking what was selected e.g 4 lines that must form a straight rectangle and if it's not, you will be notify.
if some other thing went wrong or missing (like the circle blocks) you will be notify. the circle blocks must lay totally inside the feature otherwise they will be ignored.
if your selection was positive, you will get the dimensions. the horizontal dimension starts from the lower left corner of the feature and to the right and the vertical dimension starts at the same point and up (exactly the same as seen in your sample drawing)
the program brings in consideration that the feature is not accurately drawn plus the position of the circle blocks may not be exactly on XY coordinates so a small tolerance (it's call fuzz) is allowed and it for start set to 1 drawing unit. this means if a feature has up to 1 unit digression, it will still be considered a straight rectangle so as if 2 circle blocks on X (or Y) axis has up to 1 unit digression, they will be considered on the same line.
the vertical dimension line relatively spaced to the left 6 * dimscale factor and the horizontal dimension relatively spaced below 6 * 1.35 * dimscale factor. the tolerance and the spaced (6) factor are hard coded and if you want to change them you will ask me. also the 'circle' block name you may want in future to use another name. maybe in future i will open all that for you 
enjoy
moshe