
;********  THIS PART SHOULD BE MOVE TO MENU FOR SELECT DIM-A
;**DAGP1MN
;[AutoCAD ]$S=SCREEN
;[--------]
;[  A=25  ]25.0
;[  A=30  ]30.0
;[  A=35  ]35.0
;[  A=40  ]40.0
;[  A=45  ]45.0
;[  A=50  ]50.0
;[  A=60  ]60.0
;[  A=70  ]70.0
;[  A=80  ]80.0
;[  A=90  ]90.0
;*********  END OF PART ***************************

; (IF (= (TYPE F1) 'FILE ) "YES"  (STOP))
; (IF (= (TYPE F2) 'FILE ) "YES" (STOP))


(DEFUN C:DAGP1 ()
         (SETVAR "CMDECHO" 0)
         (SETVAR "OSMODE" 0)
         (SETQ OLAY (GETVAR "CLAYER"))

  (SETQ GPSET NIL  OAL NIL  DELTA "T")
  (SETQ GPCNT NIL  GPCEN NIL GPHID NIL GPTHI NIL GPIMG NIL )
;=== START SEEK FILE ====
  (SETQ FILP "C:/acad/ACAD/SUPPORT/DAAPRE.SET" )
  (SETQ GPSET (FINDFILE FILP))
;=== END SEEK FILE ======
         (TEXTSCR)
  (IF (/= GPSET NIL) (PROGN
   (SETQ FC (OPEN FILP "r"))
    (SETQ GPCNT (READ-LINE FC))
    (SETQ GPCEN (READ-LINE FC))
    (SETQ GPHID (READ-LINE FC))
    (SETQ GPTHI (READ-LINE FC))
    (SETQ GPIMG (READ-LINE FC))
   (CLOSE FC)
  ))

  (IF (OR (= GPCNT NIL) (= GPCNT "") ) (SETQ GPCNT  "0"  ) )
  (IF (OR (= GPCEN NIL) (= GPCEN "") ) (SETQ GPCEN  "CEN") )
  (IF (OR (= GPHID NIL) (= GPHID "") ) (SETQ GPHID  "HID") )
  (IF (OR (= GPTHI NIL) (= GPTHI "") ) (SETQ GPTHI  "DIM") )
  (IF (OR (= GPIMG NIL) (= GPIMG "") ) (SETQ GPIMG  "PHA") )

  (SETQ GPSET "T")

  (WHILE DELTA
   (IF (= GPSET NIL)  (PROGN
    (PROMPT "\nPLEASE SETTING THE DATA OF LAYER:" )

    (SETQ AA GPCNT)
    (PROMPT"\nSETTING LAYER OF CONTNIUE LINE:<") (PROMPT AA) (PROMPT ">")
    (SETQ GPCNT (GETSTRING))
    (IF (= GPCNT "") (SETQ GPCNT AA) )

    (SETQ BB GPCEN)
    (PROMPT"\nSETTING LAYER OF CENTER LINE:<") (PROMPT BB) (PROMPT ">")
    (SETQ GPCEN (GETSTRING))
    (IF (= GPCEN "")   (SETQ GPCEN BB) )

    (SETQ CC GPHID)
    (PROMPT"\nSETTING LAYER OF HIDDEN LINE:<") (PROMPT CC) (PROMPT ">")
    (SETQ GPHID (GETSTRING))
    (IF (= GPHID "") (SETQ GPHID CC) )

    (SETQ DD GPTHI)
    (PROMPT"\nSETTING LAYER OF THIN LINE:<") (PROMPT DD) (PROMPT ">")
    (SETQ GPTHI (GETSTRING))
    (IF (= GPTHI "") (SETQ GPTHI DD) )

   )) ;ENDIF GP.SET=NIL

   (PROMPT "\n========================================" )
   (PROMPT "\n    NOW LAYER OF CONTINUE IS LAYER - " ) (PROMPT GPCNT)
   (PROMPT "\n    NOW LAYER OF CENTER IS LAYER --- " ) (PROMPT GPCEN)
   (PROMPT "\n    NOW LAYER OF HIDDEN IS LAYER --- " ) (PROMPT GPHID)
   (PROMPT "\n    NOW LAYER OF THIN IS LAYER ----- " ) (PROMPT GPTHI)
   (PROMPT "\n========================================" )

   (SETQ ANS (GETSTRING "\n DO YOU WANT TO CHANGE LAST SETTING ? Yes/<No> :"))
   (IF (= ANS  "")  (SETQ ANS  "N") )
   (IF (/= ANS "")  (SETQ ANS  (STRCASE (SUBSTR ANS  1 1))) )
   (IF (= ANS "Y")  (SETQ GPSET NIL) )
   (IF (= ANS "N")  (SETQ DELTA NIL) )

  ) ;ENDWHILE

  (SETQ FC (OPEN FILP "w"))
   (WRITE-LINE GPCNT FC)
   (WRITE-LINE GPCEN FC)
   (WRITE-LINE GPHID FC)
   (WRITE-LINE GPTHI FC)
   (WRITE-LINE GPIMG FC)
  (CLOSE FC)

         (GRAPHSCR)
         (MENUCMD "S=X")
         (MENUCMD "S=DAGP1MN")
         (INITGET (+ 1 2 4))
  (SETQ OAL (GETREAL"\nSelect DIM D :"))
;======== BASE DATA ==============
(IF (= OAL 25.0) (SETQ ODL 35.0 AG (DTR 10.0) HL 10.0 MR 3.0 CL 15.0 DR 2.0 BC 3.0))
(IF (= OAL 30.0) (SETQ ODL 40.0 AG (DTR 10.0) HL 10.0 MR 3.0 CL 15.0 DR 2.0 BC 3.0))
(IF (= OAL 35.0) (SETQ ODL 45.0 AG (DTR 10.0) HL 10.0 MR 3.0 CL 15.0 DR 2.0 BC 3.0))
(IF (= OAL 40.0) (SETQ ODL 50.0 AG (DTR 10.0) HL 10.0 MR 3.0 CL 15.0 DR 2.0 BC 3.0))
(IF (= OAL 45.0) (SETQ ODL 55.0 AG (DTR 10.0) HL 10.0 MR 3.0 CL 15.0 DR 2.0 BC 3.0))

(IF (= OAL 50.0) (SETQ ODL 62.0 AG (DTR 5.0) HL 15.0 MR 5.0 CL 20.0 DR 3.0 BC 4.0))
(IF (= OAL 60.0) (SETQ ODL 72.0 AG (DTR 5.0) HL 15.0 MR 5.0 CL 20.0 DR 3.0 BC 4.0))
(IF (= OAL 70.0) (SETQ ODL 82.0 AG (DTR 5.0) HL 15.0 MR 5.0 CL 20.0 DR 3.0 BC 4.0))
(IF (= OAL 80.0) (SETQ ODL 92.0 AG (DTR 5.0) HL 15.0 MR 5.0 CL 20.0 DR 3.0 BC 4.0))
(IF (= OAL 90.0) (SETQ ODL 105.0 AG (DTR 5.0) HL 15.0 MR 5.0 CL 20.0 DR 3.0 BC 4.0))

  (SETQ AL  (/ OAL 2.0))
  (SETQ AL1 (+ AL 0.75))
  (SETQ DL  (/ ODL 2.0))
  (SETQ TEST 1)
  (SETQ DL1 (+ DL 0.75)  DL2 (+ DL 2.50)  DL3 (+ DL 3.25)   )
;=========== GET POINT ===============
         (INITGET 1)
  (SETQ TEST 2)
  (SETQ P1 (GETPOINT "\nBASE POINT <P1>:"))
         (INITGET 1)
  (SETQ P2 (GETPOINT P1 "\nPOINT <P2>:"))
  (SETQ ANGS (ANGLE P1 P2))
  (SETQ ANG+ (+ ANGS (* PI 0.5)))
  (SETQ ANG- (- ANGS (* PI 0.5)))
         (INITGET 1)
  (SETQ OP3 (GETPOINT P2 "\nPOINT <P3>:"))
  (SETQ P3 (INTERS P1  P2  OP3  (POLAR OP3 ANG- 1) NIL))
         (INITGET 1)
  (SETQ OP4 (GETPOINT P3 "\nPOINT <P4>:"))
  (SETQ P4 (INTERS P1  P2  OP4  (POLAR OP4 ANG- 1) NIL))
;=== COMPUTE THE BASE DATA ============
  (SETQ L1 (DISTANCE P1 P2))
  (SETQ L2 (* AL 2.0 1.5))
  (SETQ L3 (- (DISTANCE P2 P4) L2  CL))
  (SETQ AG1 (/ (+ AG (* PI 0.5)) 2.0))
  (SETQ DRL (/ (* (COS AG1) MR) (SIN AG1)) )
  (SETQ P2P (POLAR P2 ANGS L2))
  (SETQ P4P (POLAR P2P ANGS L3))
;========== DRAWING =====================
  (SETQ DR1   (POLAR P1    ANG+ AL ))
  (SETQ DR1-1 (POLAR P1    ANG+ (- AL BC)))
  (SETQ DR1-2 (POLAR DR1   ANGS BC))
  (SETQ AR1-1 (POLAR P1    ANG+ (- AL DR)))
  (SETQ AR1-2 (POLAR DR1   ANGS DR))
  (SETQ DR2   (POLAR P2    ANG+ AL))
  (SETQ DR3   (POLAR P2P   ANG+ AL))
  (SETQ DR4   (POLAR DR2   ANGS (- (DISTANCE P2 P3) HL) ))
  (SETQ DR5   (INTERS DR4 (POLAR DR4 (- ANGS AG) 1) P3 (POLAR P3 ANG+ 1) NIL))
  (SETQ DR5-1 (POLAR DR5   ANG- DRL ))
  (SETQ DR5-2 (POLAR DR4  (ANGLE DR4 DR5) (- (DISTANCE DR4 DR5) DRL)))
  (SETQ DR6   (POLAR P1    ANG- AL ))
  (SETQ DR6-1 (POLAR P1    ANG- (- AL BC) ))
  (SETQ DR6-2 (POLAR DR6   ANGS BC))
  (SETQ AR6-1 (POLAR P1    ANG- (- AL DR)))
  (SETQ AR6-2 (POLAR DR6   ANGS DR))
  (SETQ DR7   (POLAR P2    ANG- AL))
  (SETQ DR8   (POLAR P2P   ANG- AL))
  (SETQ DR9   (POLAR DR7   ANGS (- (DISTANCE P2 P3) HL) ))
  (SETQ DR10  (INTERS DR9 (POLAR DR9 (+ ANGS AG) 1) P3 (POLAR P3 ANG- 1) NIL))
  (SETQ DR10-1 (POLAR DR10  ANG+ DRL))
  (SETQ DR10-2 (POLAR DR9  (ANGLE DR9 DR10) (- (DISTANCE DR9 DR10) DRL)))
  (SETQ DR11  (POLAR P2P   ANG+ AL1))
  (SETQ DR12  (POLAR P4    ANG+ AL1))
  (SETQ DR13  (POLAR P2P   ANG- AL1))
  (SETQ DR14  (POLAR P4    ANG- AL1))
  (SETQ DR15  (POLAR P2    ANG+ DL))
  (SETQ DR16  (POLAR P2P   ANG+ DL))
  (SETQ DR17  (POLAR P4P   ANG+ DL))
  (SETQ DR18  (POLAR P2    ANG- DL))
  (SETQ DR19  (POLAR P2P   ANG- DL))
  (SETQ DR20  (POLAR P4P   ANG- DL))
  (SETQ DR21  (POLAR P2P   ANG+ DL1))
  (SETQ DR22  (POLAR P4P   ANG+ DL1))
  (SETQ DR23  (POLAR P2P   ANG- DL1))
  (SETQ DR24  (POLAR P4P   ANG- DL1))
  (SETQ DR25  (POLAR P4P   ANG+ DL2))
  (SETQ DR26  (POLAR P4    ANG+ DL2))
  (SETQ DR27  (POLAR P4P   ANG- DL2))
  (SETQ DR28  (POLAR P4    ANG- DL2))
  (SETQ DR29  (POLAR P4P   ANG+ DL3))
  (SETQ DR30  (POLAR P4    ANG+ DL3))
  (SETQ DR31  (POLAR P4P   ANG- DL3))
  (SETQ DR32  (POLAR P4    ANG- DL3))

  (COMMAND "LAYER" "S" GPCNT "")

  (SETQ FIGC NIL )
  (SETQ FIGC (SSGET "C" DR2 DR2 ) )
  (IF (/= FIGC NIL) (COMMAND "BREAK" DR2 DR7) )
  (IF (=  FIGC NIL) (PROGN
    (COMMAND "LINE" DR15 DR2 "")
    (COMMAND "LINE" DR7 DR18 "")
  ))

  (SETQ FIGC NIL )
  (SETQ FIGC (SSGET "C" DR12 DR12 ) )
  (IF (= FIGC NIL) (COMMAND "LINE" DR30 DR32 "") )

  (COMMAND "ARC" AR1-2  "E" AR1-1   "R"  DR )
  (COMMAND "ARC" AR6-1  "E" AR6-2   "R"  DR )
  (COMMAND "ARC" DR5-1  "E" DR5-2   "R"  MR )
  (COMMAND "ARC" DR10-2 "E" DR10-1  "R"  MR )

  (SETQ P3P (INTERS P2 P3 DR5-2 DR10-2 NIL))

  (IF (<= L2 (DISTANCE DR2 DR4))  (PROGN
    (COMMAND "LINE" DR11 DR3   "")
    (COMMAND "LINE" DR13 DR8   "")
  ))

  (IF (AND (<= L2 (DISTANCE  P2  P3P)) (> L2 (DISTANCE DR2 DR4)) ) (PROGN
    (COMMAND "LINE" DR11 (INTERS DR11 DR3 DR4 DR5  NIL)  "")
    (COMMAND "LINE" DR13 (INTERS DR13 DR8 DR9 DR10 NIL)  "")
  ))

  (IF (> L2 (DISTANCE  P2  P3)) (COMMAND "LINE" DR11 DR13  "")   )

  (IF (AND (<= L2 (DISTANCE  P2  P3 )) (> L2 (DISTANCE  P2 P3P)) ) (PROGN
    (COMMAND "LINE" DR11 DR3   "")
    (COMMAND "LINE" DR13 DR8   "")
    (COMMAND "EXTEND" "C" DR5-2 DR5-2 ""  DR3 "")
    (COMMAND "EXTEND" "C" DR10-2 DR10-2 ""  DR8 "")
  ))

  (COMMAND "LINE" AR1-1 AR6-1 "")
  (COMMAND "LINE" DR1-2 DR1-1 "")
  (COMMAND "LINE" DR6-1 DR6-2 "")
  (COMMAND "LINE" AR1-2 DR4 DR5-2 "")
  (COMMAND "LINE" AR6-2 DR9 DR10-2 "")
  (COMMAND "LINE" DR5-1 DR10-1 "")
  (COMMAND "LINE" DR11 DR12 "")
  (COMMAND "LINE" DR13 DR14 "")
  (COMMAND "LINE" DR15 DR17 DR29 DR30 "")
  (COMMAND "LINE" DR18 DR20 DR31 DR32 "")
  (COMMAND "LINE" DR21 DR22 "")
  (COMMAND "LINE" DR23 DR24 "")
  (COMMAND "LINE" DR25 DR26 "")
  (COMMAND "LINE" DR27 DR28 "")
  (COMMAND "LINE" DR21 DR16 "")
  (COMMAND "LINE" DR19 DR23 "")

  (COMMAND "LAYER" "S" GPHID  "")
  (COMMAND "LINE" DR2  DR7  "")

  (COMMAND "LAYER" "S" GPTHI  "")
  (COMMAND "LINE" DR4  DR9  "")

  (COMMAND "LAYER" "S" GPCEN  "")
  (COMMAND "LINE"  (POLAR P1 (ANGLE P4 P1) 1.5 ) (POLAR P4 ANGS 1.5 )  "")

         (MENUCMD "S=SCREEN")
         (COMMAND "LAYER" "S" OLAY  "")
         (SETVAR "CMDECHO" 1)
         (PROMPT "\n OK !!")
)
