I'm trying to establish a routine that draws duct. Before anything I'd like to get the users input (or partial input) and compute the rest. I'm also trying to check that the piece that the user is inputting CAN be made. That is, it will fit on the material and will not severly restrict air flow. however the initial setup is becoming so convoluted that i can't see the flaw..can anyone tell me why I can't get out of this loop?
(defun mytest ()
(setq #dep1 24.0 ;for test purposes
#wid1 12.0
)
(if (or (> #wid1 24) (> #dep1 24))
(setq stock 59.25
slips 1.375
)
(setq stock 60.0
slips 0.5
)
)
;;fill in blanks, if any
(if st1
nil
(setq st1 2.0)
)
(if st2
nil
(setq st2 2.0)
)
;;;calc max and min duct sizes (to fit on sheet)
(setq slpmat (- stock (+ st1 st2 (* slips 2.0)))
area_sqin (* #wid1 #dep1) ;area in sq inches
)
(while
(setq offer (sqrt area_sqin))
;;;Ask for width, offer square
(setq
#wid2 (getreal
(strcat "\nEnter duct WIDTH2 <" (rtos offer 5 1) ">:")
)
)
;;;if a width value is entered, ask for depth re-calculate offer based on area
(if #wid2
(progn
(setq offer (/ area_sqin #wid2))
(setq
#dep2
(getreal
(strcat "\nEnter duct DEPTH2 <" (rtos offer 5 1) ">:")
)
)
)
;;;if no width value entered ask for depth use original square of area as offer
(setq
#dep2 (getreal
(strcat "\nEnter duct DEPTH2 <" (rtos offer 5 1) ">:")
)
)
)
;;;if a depth value is entered, verify width by re-calculation
(if (and (null #wid2) #dep2)
(progn
(setq offer (/ area_sqin #dep2))
(setq
#wid2
(getreal
(strcat "\nEnter duct WIDTH2 <" (rtos offer 5 1) ">:")
)
)
)
)
;;;if width has been left null set it offer (square)
(if (null #wid2)
(setq #wid2 offer)
)
;;;if depth has been left null set it to offer (square)
(if (null #dep2)
(setq #dep2 offer)
)
(if
(or (> (/ (abs (- #wid1 #wid2)) 2.0) slpmat)
(> (/ (abs (- #dep1 #dep2)) 2.0) slpmat)
)
(prompt "\nAdjust aspect ratio is FUBAR...try again")
nil
)
) ;while
)