Click
here
to download AutoLISP file.
Click
here
to view source code.