I agree that it's a daunting prospect to imagine how that could be automated. For example, along the longer top-edge segment of your sample boundary, the shapes need to be pushed up so that their top right corners touch the boundary, but along the shorter upper-left-corner segment, because of the different direction of slope, it would need to be their top left corners. A routine would need to account for the direction of the slope of the boundary at a give location, to figure which part of an object to base its position on.
And could the boundary ever involve arc segments? That would open up the possibility that the same boundary segment could want some objects positioned along it based on a different location on them than other objects.
A routine would need to somehow decide where on such a boundary to start, and in which direction to proceed. [Fortunately, it is at least possible to determine from a closed Polyline where the inside is vs. the outside -- lots of routines about that on these Forums.] In the image below, the left one starts with a shape meeting the upper right corner, and proceeds leftward from there along the top edge; the right one starts with one in the lower right [though since it doesn't actually meet that corner, finding the exact positioning of it by code, to touch both adjacent boundary edges, would be a real challenge], and proceeds leftward along the bottom edge. The right one gets in one more object, but it may not be possible to find the optimal solution except by running through whatever the process is under all possible scenarios and comparing the results.

And what are the "objects" involved? If they're single Polylines, it's conceivable that (intersectwith) methods could be used to help position them, and possibly to decide that there isn't room for any in your little tail area on the left, though probably only by putting one in, and finding it intersects the boundary too many times. But if they're Blocks, or if they're made up of four Lines each, or more than one Polyline, or maybe some other possibilities, it's hard to imagine how they could be positioned.
All sorts of questions arise.... Are the "objects" always rectangular, or could they be other shapes? Are they always orthogonally oriented, or might they be at other angles? Would a routine ideally somehow determine at what angle the most can be fit in? [That would probably have some relationship to the longest boundary segment.] Is there some standard for the spacing between them, and would that always be the same? Is there some basis for the difference between the horizontal and vertical spacings between them?
If the objects could be different shapes, something like the left image below might be achievable in the same way as with rectangles, but far less efficient than the right side, which would be extremely difficult to achieve by code, if even possible.

Etc., etc., etc. -- those are just some of the difficulties that come to mind in a quick consideration.
Kent Cooper, AIA