I am trying to make a button such that if the user clicks it, AutoCAD will automatically draw a border that just includes all entities in the drawing. (Something like the view port border in the paperspace)
Approach #1
The first approach could be zoom extent and draw a border around the zoomed view. But for this, I know how to zoom extent and draw a polyline, but can't figure out the exact size of zoomed view.
Approach #2 (optimal)
If the entity is a right circle and my AutoCAD window is not in square shape (for example, the AutoCAD window is maximized and my monitor is wide-scrren monitor), Approach #1 will create redundant spaces at the right and left side of the circle entity. So if I could get the grid coordinate of far left, far right, top, and bottom entities, I can draw the optimal border around all entities in the drawing.
If anyone knows the trick and can teach me, it would be very appreciated. :)
Clik here to view.

Clik here to view.

Clik here to view.

Clik here to view.

Clik here to view.

Clik here to view.
