Last week, I needed create a scale drawing of my basement floor plan. My license for OmniGraffle Professional are long since out-of-date. I didn’t want to pay $200 for a new license or even another $75 if I can dig up one of my old license keys. So, what’s a hacker to do? Roll his own (on top of Zach’s Vecto library).

My first cut worked, but was pretty ugly:

( with-floor-plan #P "basement.png" 200.0

( interior-wall : start ( cons ( - 91 31 1 / 2 ) 0 ) ; hose cover

: north 18

: east ( + 31 1 / 2 ) )

( interior-wall : start ( cons 91 ( - 103 27 30 ) ) ; storage wall

: south ( - 103 27 30 ) )

( interior-wall : start ( cons ( + 91 83 ) 103 ) ; fish-tank wall

: to ' ( 91 . 103 )

: south 27 )

... )



I ended up with large calculations like that (- 103 27 30) you see there. It worked. I got an okay looking floor-plan out of it. But, it was obvious that it needed some rethinking.

My next thought was turtle graphics! Tell things where to move. Tell it to start drawing an interior wall. Tell it where to move. Tell it to start drawing a window. Tell it where to move. Tell it to stop drawing a window. Etc. This has possibilities, especially for an internal representation (which I need because I want to autoscale the drawing to fit on a sheet of paper well, so I can’t start drawing until I’ve determined the extents). However, it seems awkward to go with all of the start/stop commands. I am thinking of going more in this sort of direction:

;; The floor-plan stuff works in units. To facility readability, I am

;; going to make some simple functions that use feet and inches instead

;; of units. If you want centimeters and meters, go for it.



( flet ( ( feet ( n ) ( * n 12 ) )

( inches ( n ) n ) )

( with-floor-plan ( #P "floor-plan.png"

: max-width 8.0 ; maximum width of output (units)

: max-height 10.0 ; maximum height of output (units)

: dots-per-unit 300.0 ; resolution of output

: grid ( inches 6 ) ) ; size of background-grid



( compass : north 180.0 ) ; draw north indication 180 degrees CCW from right



( exterior-wall ; start drawing an exterior wall

: closed t ; that closes at the end

( left ( feet 10 ) ) ; extend wall left 10 feet

( up ( feet 6 ) ) ; extend wall up 6 feet

( window

( up ( inches 30 ) ) ) ; draw 30" window

( up ( inches 8 ) ) ; draw 8" wall

( door : starts : hinge-side ; or :latch-side

: opens : left ; or :right seen from direction of motion

( up ( inches 30 ) ) ) ; this door goes up, so :left is to

; the left of the page

( up ( inches 8 ) )

( right ( feet 10 ) ) )



( left ( feet 4 ) ) ; move four feet to the left

( interior-wall

( up ( feet 5 ) )

( right ( inches 8 ) )

( door : starts : latch-side

: opens : right

( right ( inches 30 ) ) )

( right-to ( feet 0 ) ) ) ; move to an absolute left-right coordinate

( move ( feet 2 ) ( feet ( + 2 1 / 2 ) ) )

( label "Bathroom" ) ) )

Has anyone tackled this problem well already? Or, have any suggestions of how to improve this?