For some reason I am having a problem with a custom program I have written to draw a Full Radius Duct Elbow at Variable degree turn. What is happening, in my COND statement, the variable SPA1 is not having anything assigned to it. I do know that that means for some reason, the Variables that need to have conditons meet are not. Here is how the program operates: 1. User picks existing line - end of duct trunk 2. User selects Yes/No for Duct Liner - not programed yet 3. User selects Radius of Elbow - 15-90 deg - 90 Default 4. User picks starting direction of Radius Elbow 5. User picks ending direction of Radius Elbow The problem is, when the user picks the Radius Elbow direction of: Starting Direction: 0 Ending Direction: 270 or Staring Direction: 270 Ending DIrection: 0 Is when the program fails. Please advise if I have something incorrect. TIA, Craig (DEFUN C:ELBOW (/ SLine LType) (LOAD "ERROR") (INITERR) ;;; (SETVAR "MENUECHO" 1) ;;; (SETVAR "CMDECHO" 0) (SETQ Liner (STRCASE (GETSTRING "\nShow Liner? Y/N <Y>: ")) DRadis (GETSTRING "\nRadius of Elbow (15-90 deg) <90>: ") ) ;_ end of SETQ (IF (= Liner "N") (SETQ Liner "") (SETQ Liner "Y") ) ;_ end of IF (IF (= DRadis "") (SETQ DRadis "90") ) ;_ end of IF (WHILE (/= "LINE" LType) (SETQ SLine (ENTGET (CAR (ENTSEL "\nFrom Point: "))) LType (CDR (ASSOC 0 SLine)) ) ;_ end of SETQ ) ;_ end of WHILE (SETQ PT1 (CDR (ASSOC 10 SLine)) PT2 (CDR (ASSOC 11 SLine)) Ang1 (ANGLE PT1 PT2) Dis1 (DISTANCE PT1 PT2) Dis2 (/ Dis1 2) TPT1 (POLAR PT1 Ang1 Dis2) TPT2 (GETPOINT TPT1 "\nStarting Direction: ") APT1 (ANGLE TPT1 TPT2) TPT3 (POLAR TPT1 APT1 (* Dis1 1.5)) TPT4 (GETPOINT TPT3 "\nEnding Direction: ") APT2 (ANGLE TPT3 TPT4) CPT1 (POLAR TPT1 APT2 (* Dis1 1.5)) Ang2 (RTD APT1) Rad1 (ATOI DRadis) APT1d (RTD APT1) APT2d (RTD APT2) ) ;_ end of SETQ (COND ((AND (<= APT1d 90.0) (>= APT1d 0.0) (<= APT2d 0.0) (>= APT2d 270.0)) (SETQ SPA1 (DTR (+ Ang2 (- 90.0 Rad1)))) (PRINC "1") ) ;_ add ((AND (<= APT1d 90.0) (>= APT1d 0.0) (<= APT2d 180.0) (>= APT2d 90.0)) (SETQ SPA1 (DTR (- Ang2 (- 90.0 Rad1)))) (PRINC "2") ) ;_ sub ((AND (<= APT1d 180.0) (>= APT1d 90.0) (<= APT2d 270.0) (>= APT2d 180.0)) (SETQ SPA1 (DTR (- Ang2 (- 90.0 Rad1)))) (PRINC "3") ) ;_ sub ((AND (<= APT1d 180.0) (>= APT1d 90.0) (<= APT2d 90.0) (>= APT2d 0.0)) (SETQ SPA1 (DTR (+ Ang2 (- 90.0 Rad1)))) (PRINC "4") ) ;_ add ((AND (<= APT1d 270.0) (>= APT1d 180.0) (<= APT2d 0.0) (>= APT2d 270.0)) (SETQ SPA1 (DTR (- Ang2 (- 90.0 Rad1)))) (PRINC "5") ) ;_ sub ((AND (<= APT1d 270.0) (>= APT1d 180.0) (<= APT2d 180.0) (>= APT2d 90.0)) (SETQ SPA1 (DTR (+ Ang2 (- 90.0 Rad1)))) (PRINC "6") ) ;_ add ((AND (<= APT1d 0.0) (>= APT1d 270.0) (<= APT2d 270.0) (>= APT2d 180.0)) (SETQ SPA1 (DTR (+ Ang2 (- 90.0 Rad1)))) (PRINC "7") ) ;_ add ((AND (<= APT1d 0.0) (>= APT1d 270.0) (<= APT2d 90.0) (>= APT2d 0.0)) (SETQ SPA1 (DTR (- Ang2 (- 90.0 Rad1)))) (PRINC "8") ) ;_ sub ) ;_ end of COND (ALERT "LOOK WHERE I AM AT") (SETQ PT3 (POLAR TPT1 (+ PI APT2) Dis2) PT4 (POLAR TPT1 APT2 Dis2) PT5 (POLAR CPT1 SPA1 Dis1) PT6 (POLAR PT5 SPA1 Dis1) ) ;_ end of SETQ (COMMAND "ARC" PT4 "E" PT5 "D" (RTD APT1)) (COMMAND "ARC" PT3 "E" PT6 "D" (RTD APT1)) (COMMAND "LINE" PT5 PT6 "") ;;; (RESETERR) ) ;_ end of DEFUN (DEFUN DTR (a) (* PI (/ a 180.0)) ) ;_ end of defun (DEFUN RTD (a) (* 180.0 (/ a PI)) ) ;_ end of defun
(cond ((and (<= apt1d 90.0) (>= apt1d 0.0) (<= apt2d 0.0) (>= apt2d 270.0)) (setq spa1 (dtr (+ ang2 (- 90.0 rad1)))) (princ "1")) ((and (<= apt1d 90.0) (>= apt1d 0.0) (<= apt2d 180.0) (>= apt2d 90.0)) (setq spa1 (dtr (- ang2 (- 90.0 rad1)))) (princ "2")) ((and (<= apt1d 180.0) (>= apt1d 90.0) (<= apt2d 270.0) (>= apt2d 180.0)) (setq spa1 (dtr (- ang2 (- 90.0 rad1)))) (princ "3")) ((and (<= apt1d 180.0) (>= apt1d 90.0) (<= apt2d 90.0) (>= apt2d 0.0)) (setq spa1 (dtr (+ ang2 (- 90.0 rad1)))) (princ "4")) ((and (<= apt1d 270.0) (>= apt1d 180.0) (<= apt2d 0.0) (>= apt2d 270.0)) (setq spa1 (dtr (- ang2 (- 90.0 rad1)))) (princ "5")) ((and (<= apt1d 270.0) (>= apt1d 180.0) (<= apt2d 180.0) (>= apt2d 90.0)) (setq spa1 (dtr (+ ang2 (- 90.0 rad1)))) (princ "6")) ((and (<= apt1d 0.0) (>= apt1d 270.0) (<= apt2d 270.0) (>= apt2d 180.0)) (setq spa1 (dtr (+ ang2 (- 90.0 rad1)))) (princ "7")) ((and (<= apt1d 0.0) (>= apt1d 270.0) (<= apt2d 90.0) (>= apt2d 0.0)) (setq spa1 (dtr (- ang2 (- 90.0 rad1)))) (princ "8"))) {this is just the same re-formatted, plus whatever the newsreader does to clobber formatting} - It might be usable to have a debugging printout of the values of apt1d and apt2d before the cond for hand-testing - You should perhaps add a T -branch to the cond to report missed choices - You seem to have a little logical problem: you have a condition where apt2d should be both lesser than 0 and greater than 270. Where you meaning OR instead of AND ? - It might be clearer to show intervals like (<= 180.0 apt1d 270.0) - It might be safer to create a few constants for often-used angles in radians, and write all the calculations in radians: now you have deg-to-rad conversions scattered around, so it is easy to miss one. --