PDA

View Full Version : Cleaning up an old routine


tflaherty
2005-05-18, 12:35 AM
I inherited this routine form the previous CAD Manager and I'm just trying to clean it up and document it. The below portion of the routine draws the drawer fronts on lower cabinets and the drawer pull. It all works fine, but I'm thinking there's got to be an easier and cleaner way of finding the insertion point for the drawer pull (see the line "(setq DPI..."

Thanks for your help

(setq D3 (sqrt 2))
(setq DIC1 (polar DC1 A D3))
(setq DIC3 (list (- (+ (car DC1) DW) 1) (+ (cadr CC3) 4.5)))
(setq DIC2 (list (car DIC1) (cadr DIC3)))
(setq DIC4 (list (car DIC3) (cadr DIC1)))
(command "line" DIC1 DIC2 DIC3 DIC4 "c")
(setq DPI (list (+ (/ (- (car DIC3) (car DIC2)) 2) (car DIC2)) (+ (cadr DIC1) 1)))
(command "circle" DPI ".5")
(command "line" DC1 DIC1 "")
(command "line" DC2 DIC2 "")
(command "line" DC3 DIC3 "")
(command "line" DC4 DIC4 "")

miff
2005-05-18, 01:17 AM
I don't follow what it's trying to do, exactly, but if the intent is to place the pull at the middle of the drawer then this will work:

(setq dpi (inters DIC1 DIC3 DIC2 DIC4))

ddenton
2009-07-08, 11:14 PM
in the interest of cleaning up, you might combine the (setq...'s
(setq D3 (sqrt 2)
DIC1 (polar DC1 A D3)
DIC3 (list (- (+ (car DC1) DW) 1) (+ (cadr CC3) 4.5))
DIC2 (list (car DIC1) (cadr DIC3))
DIC4 (list (car DIC3) (cadr DIC1))
)

personally, i would combine all the (command...'s too

(command "circle" DPI ".5"
"line" DC1 DIC1 ""
"line" DC2 DIC2 ""
"line" DC3 DIC3 ""
"line" DC4 DIC4 ""
)

IIRC, (command... can have some overhead each time it's called, so by calling it once there can be less of a performance hit.