This seemed like a fun challenge, so I thought I might participate...
Here is my version:
The attached program will prompt for a rectangular closed LWPolyline and a 'wire spacing' (the distance between the coils), and will generate a maximal filleted spiral centered within the selected LWPolyline.
The program should perform successfully with all rectangular closed LWPolylines, at any rotation or orientation, and in all UCS & Views.
For an arbitrary rectangle of any dimension, one cannot specify both the spacing between the coils and the offset from the rectangle boundary, since multiples of these values will not necessary equate to the rectangular dimensions.
Hence, my program will prompt for the spacing between the coils and will center the spiral within the selected rectangular LWPolyline, maximising the number of spiral coils for the given spacing, with the division remainder equal to the offset from the boundary.
If the spacing is a multiple of the dimensions of the boundary, the program will offset the spiral from the boundary by the given spacing to ensure that the coils do not touch the boundary edge.
The code isn't pretty, but should hopefully perform correctly.
Interesting challenge!
HeatGridV1-0.lsp