; *************************************************************************
; *************************************************************************
; *** ***
; *** PIPE & FLANGE DRAUGHTSMAN by LEE McDONNELL ***
; *** COPYRIGHT (C) SEPTEMBER 2008 ***
; *** ***
; *** ***
; *** AutoLISP Routine written and developed for AutoCAD 2004 ***
; *** by Lee McDonnell ***
; *** ***
; *** ***
; *** Function Syntax: PF ***
; *** ***
; *** ***
; *** Will draw a flange, pipe, elbow or tee ***
; *** of a predetermined ***
; *** size at a selected point. ***
; *** ***
; *** ***
; *** FLANGE & PIPE DIMENSION LIBRARY ***
; *** ***
; *** PIPE DIMENSION LIBRARY -- ANSI B 36.10-1979 ***
; *** (Pipes are Sch 40) ***
; *** ***
; *** PIPE BORE O/D WALL (I/D) ***
; *** (in) (mm) ***
; *** ***
; *** 2 50NB 60.3 3.91 52.48 ***
; *** 3 80NB 88.9 5.49 77.92 ***
; *** 4 100NB 114.3 6.02 102.26 ***
; *** 6 150NB 168.3 7.11 154.08 ***
; *** 8 200NB 219.1 8.18 202.74 ***
; *** 10 250NB 273.1 9.27 254.56 ***
; *** ***
; *** ***
; *** FLANGE (plan) DIMENSION LIBRARY -- ANSI B 16-5-1981 ***
; *** (Flanges are ANSI 150 RF) ***
; *** ***
; *** PIPE BORE O/D PCD BORE BOLTS ***
; *** (in) (mm) (num) (dia) ***
; *** ***
; *** 2 50NB 152 120.6 62.0 4 19.0 ***
; *** 3 80NB 190 152.4 90.7 4 19.0 ***
; *** 4 100NB 229 190.5 116.1 8 19.0 ***
; *** 6 150NB 279 241.3 170.7 8 22.2 ***
; *** 8 200NB 343 298.4 221.5 8 22.2 ***
; *** 10 250NB 406 362.0 276.4 12 25.4 ***
; *** ***
; *** ***
; *** FLANGE (elevation) DIMENSION LIBRARY -- ANSI B 16-5-1981 ***
; *** (Flanges are ANSI 150 RF) ***
; *** ***
; *** PIPE BORE R X Y C F ***
; *** (in) (mm) (face) (depth) ***
; *** ***
; *** 2 50NB 92.1 78.0 25.0 19.1 1.6 ***
; *** 3 80NB 127.0 108.0 30.0 23.9 1.6 ***
; *** 4 100NB 157.2 135.0 33.0 23.9 1.6 ***
; *** 6 150NB 215.9 192.0 40.0 25.4 1.6 ***
; *** 8 200NB 269.9 246.0 44.0 28.6 1.6 ***
; *** 10 250NB 323.8 305.0 49.0 30.2 1.6 ***
; *** ***
; *** ***
; *** TEE DIMENSION LIBRARY -- ANSI B 16-9-1978 ***
; *** (Tees are equal) ***
; *** ***
; *** PIPE BORE PIPE O/D PIPE I/D C/M ***
; *** (in) (mm) ***
; *** ***
; *** 2 50NB 60.3 52.48 64.0 ***
; *** 3 80NB 88.9 77.92 86.0 ***
; *** 4 100NB 114.3 102.26 105.0 ***
; *** 6 150NB 168.3 154.08 143.0 ***
; *** 8 200NB 219.1 202.74 178.0 ***
; *** 10 250NB 273.1 254.56 216.0 ***
; *** ***
; *** ***
; *** Version 2.1 ~ Added Layer Creator Code (supplied by ASMI) ***
; *** ***
; *** Version 2.1.1 ~ Added Layer Colour Code ***
; *** ***
; *** Version 2.2 ~ Added Tee Plan Code ***
; *** ***
; *************************************************************************
; *************************************************************************

;;; Modified by Igal Averbuh 2016

; ***** Flange Plan User Input *****

(defun userflangevalues ()
(setq flgpt1 (getpoint "\nSelect Point for Flange Insertion: "))
(initget 1 "50 80 100 150 200 250")
(setq flgsize (getkword "\nSelect Flange Size [50/80/100/150/200/250]: "))
) ; end user input flange plan program

;
***** Flange Elevation User Input *****

(defun userflangeelevvalues ()
(setq flgept1 (getpoint "\nSelect Point for Flange Insertion: "))
(initget 1 "50 80 100 150 200 250")
(setq flgesize (getkword "\nSelect Flange Size [50/80/100/150/200/250]: "))
) ; end user input flange elevation program

; ***** Flange Variable Setter *****

(defun flangevariablesetter ()
(if ; *** 50NB FLANGE ***
(= flgsize "50")
(progn
(setq
pipeod 60.3
pipeid 52.48
flgod 152.0
flgpcd 120.6
flgbor 62.0
boltnum 4
boltdia 19.0
) ; end setq
); end progn
) ; end if
(if ; *** 80NB FLANGE ***
(= flgsize "80")
(progn
(setq
pipeod 88.9
pipeid 77.92
flgod 190.0
flgpcd 152.4
flgbor 90.7
boltnum 4
boltdia 19.0
) ; end setq
) ; end progn
) ; end if
(if ; *** 100NB FLANGE ***
(= flgsize "100")
(progn
(setq
pipeod 114.3
pipeid 102.26
flgod 229.0
flgpcd 190.5
flgbor 116.1
boltnum 8
boltdia 19.0
) ; end setq
) ; end progn
) ; end if
(if ; *** 150NB FLANGE ***
(= flgsize "150")
(progn
(setq
pipeod 168.3
pipeid 154.08
flgod 279.0
flgpcd 241.3
flgbor 170.7
boltnum 8
boltdia 22.2
) ; end setq
) ; end progn
) ; end if
(if ; *** 200NB FLANGE ***
(= flgsize "200")
(progn
(setq
pipeod 219.1
pipeid 202.74
flgod 343.0
flgpcd 298.4
flgbor 221.5
boltnum 8
boltdia 22.2
) ; end setq
) ; end progn
) ; end if
(if ; *** 250NB FLANGE ***
(= flgsize "250")
(progn
(setq
pipeod 273.1
pipeid 254.56
flgod 406.0
flgpcd 362.0
flgbor 276.4
boltnum 12
boltdia 25.4
) ; end setq
) ; end progn
) ; end if
) ; end program

; ***** Flange Elevation Variable Setter *****

(defun flangeelevvariablesetter ()
(if ; *** 50NB FLANGE ***
(= flgesize "50")
(progn
(setq
pipeod 60.3
pipeid 52.48
flgod 152.0
flgpcd 120.6
flgbor 62.0
boltnum 4
boltdia 19.0
flgr 92.1
flgx 78.0
flgy 25.0
flgc 19.1
flgf 1.6
fillrad 2.0
) ; end setq
); end progn
) ; end if
(if ; *** 80NB FLANGE ***
(= flgesize "80")
(progn
(setq
pipeod 88.9
pipeid 77.92
flgod 190.0
flgpcd 152.4
flgbor 90.7
boltnum 4
boltdia 19.0
flgr 127.0
flgx 108.0
flgy 30.0
flgc 23.9
flgf 1.6
fillrad 2.5
) ; end setq
) ; end progn
) ; end if
(if ; *** 100NB FLANGE ***
(= flgesize "100")
(progn
(setq
pipeod 114.3
pipeid 102.26
flgod 229.0
flgpcd 190.5
flgbor 116.1
boltnum 8
boltdia 19.0
flgr 157.2
flgx 135.0
flgy 33.0
flgc 23.9
flgf 1.6
fillrad 3.0
) ; end setq
) ; end progn
) ; end if
(if ; *** 150NB FLANGE ***
(= flgesize "150")
(progn
(setq
pipeod 168.3
pipeid 154.08
flgod 279.0
flgpcd 241.3
flgbor 170.7
boltnum 8
boltdia 22.2
flgr 215.9
flgx 192.0
flgy 40.0
flgc 25.4
flgf 1.6
fillrad 4.0
) ; end setq
) ; end progn
) ; end if
(if ; *** 200NB FLANGE ***
(= flgesize "200")
(progn
(setq
pipeod 219.1
pipeid 202.74
flgod 343.0
flgpcd 298.4
flgbor 221.5
boltnum 8
boltdia 22.2
flgr 269.9
flgx 246.0
flgy 44.0
flgc 28.6
flgf 1.6
fillrad 5.0
) ; end setq
) ; end progn
) ; end if
(if ; *** 250NB FLANGE ***
(= flgesize "250")
(progn
(setq
pipeod 273.1
pipeid 254.56
flgod 406.0
flgpcd 362.0
flgbor 276.4
boltnum 12
boltdia 25.4
flgr 323.8
flgx 305.0
flgy 49.0
flgc 30.2
flgf 1.6
fillrad 6.0
) ; end setq
) ; end progn
) ; end if
) ; end program

; ***** Flange Plan Draw *****

(defun flangedraw ()
(setvar "clayer" "1")
(command "_circle"
flgpt1
"D"
pipeid
) ; end circle
(command "_circle"
flgpt1
"D"
pipeod
)
(setvar "clayer" "3")
(command "_circle"
flgpt1
"D"
flgod
)
(command "_circle"
flgpt1
"D"
flgbor
)
(setvar "clayer" "5")
(command "_circle"
flgpt1
"D"
flgpcd
)
(setq boltang
(/ 360.0
(* boltnum 2)
) ; end division
) ; end setq
(setq boltcent
(polar flgpt1 (/ pi 2) (/ flgpcd 2))
) ; end setq
(setvar "clayer" "3")
(command "_circle"
boltcent
"D"
boltdia
)
(setq boltcirc (entlast))
(setvar "clayer" "5")
(setq bclleng
(+ (/ boltdia 2) 3)
) ; end setq
(setq bclbpt
(polar
boltcent
(* 3 (/ pi 2))
bclleng
) ; end polar
) ; end setq
(setq bcltpt
(polar
boltcent
(/ pi 2)
bclleng
) ; end polar
) ; end setq
(command "_line"
bclbpt
bcltpt ""
)
(setq boltcl (entlast))
(command "_rotate"
boltcirc
boltcl ""
flgpt1
boltang
) ; end rotate
(command "-array"
boltcirc
boltcl ""
"P"
flgpt1
boltnum
"360"
"Y"
) ; end array
(setq flgcltppt
(polar
flgpt1
(/ pi 2)
(+ (/ flgod 2) 30)
) ; end polar
) ; end setq
(setq flgclbtpt
(polar
flgpt1
(/ (* 3 pi) 2)
(+ (/ flgod 2) 30)
) ; end polar
) ; end setq
(command "_line"
flgcltppt
flgclbtpt ""
) ; end line
(setq flgclltpt
(polar
flgpt1
pi
(+ (/ flgod 2) 30)
) ; end polar
) ; end setq
(setq flgclrtpt
(polar
flgpt1
0
(+ (/ flgod 2) 30)
) ; end polar
) ; end setq
(command "_line"
flgclltpt
flgclrtpt ""
) ; end line
(command "regenall")
) ; end flange plan draw

; ***** Flange Elevation Draw *****

(defun flangeelevdraw ()
(setvar "clayer" "3")
(setq flgrtppt
(polar
flgept1
(/ pi 2)
(/ flgr 2)
) ; end polar
) ; end setq
(setq flgrbtpt
(polar
flgept1
(/ (* pi 3) 2)
(/ flgr 2)
) ; end polar
) ; end setq
(command "_line"
flgrtppt
flgrbtpt ""
) ; end line
(setq a1 (entlast))
(setq flgrltppt
(polar
flgrtppt
pi
flgf
) ; end polar
) ; end setq
(setq flgrlbtpt
(polar
flgrbtpt
pi
flgf
) ; end polar
) ; end setq
(command "_line"
flgrtppt
flgrltppt ""
) ; end line
(setq a2 (entlast))
(command "_line"
flgrbtpt
flgrlbtpt ""
) ; end line
(setq a3 (entlast))
(setq flgotppt
(polar
flgrltppt
(/ pi 2)
(- (/ flgod 2) (/ flgr 2))
) ; end polar
) ; end setq
(setq flgobtpt
(polar
flgrlbtpt
(/ (* pi 3) 2)
(- (/ flgod 2) (/ flgr 2))
) ; end polar
) ; end setq
(command "_line"
flgrltppt
flgotppt ""
) ; end line
(setq a4 (entlast))
(command "_line"
flgrlbtpt
flgobtpt ""
) ; end line
(setq a5 (entlast))
(setq flgoltppt
(polar
flgotppt
pi
(- flgc flgf)
) ; end polar
) ; end setq
(command "_line"
flgotppt
flgoltppt ""
) ; end line
(setq a6 (entlast))
(setq flgolbtpt
(polar
flgobtpt
pi
(- flgc flgf)
) ; end polar
) ; end setq
(command "_line"
flgobtpt
flgolbtpt ""
) ; end line
(setq a7 (entlast))
(setq flgxrtppt
(polar
flgoltppt
(/ (* pi 3) 2)
(- (/ flgod 2) (/ flgx 2))
) ; end polar
) ; end setq
(command "_line"
flgoltppt
flgxrtppt ""
) ; end line
(setq a8 (entlast))
(setq flgxrbtpt
(polar
flgolbtpt
(/ pi 2)
(- (/ flgod 2) (/ flgx 2))
) ; end polar
) ; end setq
(command "_line"
flgolbtpt
flgxrbtpt ""
) ; end line
(setq a9 (entlast))
(setq flgxtppt
(polar
flgxrtppt
pi
(- flgy flgc)
) ; end polar
) ; end setq
(command "_line"
flgxrtppt
flgxtppt ""
) ; end line
(setq a10 (entlast))
(setq flgxbtpt
(polar
flgxrbtpt
pi
(- flgy flgc)
) ; end polar
) ; end setq
(command "_line"
flgxrbtpt
flgxbtpt ""
) ; end line
(setq a11 (entlast))
(command "_line"
flgxbtpt
flgxtppt ""
) ; end line
(setq a12 (entlast))
(setvar "clayer" "1")
(setq tpboreliner
(polar
flgept1
(/ pi 2)
(/ flgbor 2)
) ; end polar
) ; end setq
(setq tpborelinel
(polar
tpboreliner
pi
flgy
) ; end polar
) ; end setq
(command "_line"
tpboreliner
tpborelinel ""
) ; end line
(setq a13 (entlast))
(setq btboreliner
(polar
flgept1
(/ (* pi 3) 2)
(/ flgbor 2)
) ; end polar
) ; end setq
(setq btborelinel
(polar
btboreliner
pi
flgy
) ; end polar
) ; end setq
(command "_line"
btboreliner
btborelinel ""
) ; end line
(setq a14 (entlast))
(setvar "clayer" "5")
(setq tpboltclr
(polar
flgept1
(/ pi 2)
(/ flgpcd 2)
) ; end polar
) ; end setq
(setq tpboltcll
(polar
tpboltclr
pi
(+ flgc 1.6)
) ; polar
) ; setq
(command "_line"
tpboltclr
tpboltcll ""
) ; end line
(setq a15 (entlast))
(setq btboltclr
(polar
flgept1
(/ (* pi 3) 2)
(/ flgpcd 2)
) ; end polar
) ; end setq
(setq btboltcll
(polar
btboltclr
pi
(+ flgc 1.6)
) ; polar
) ; setq
(command "_line"
btboltclr
btboltcll ""
) ; end line
(setq a16 (entlast))
(setvar "clayer" "1")
(setq tpbolttpptr
(polar
(polar
tpboltclr
pi
1.6
) ; end polar
(/ pi 2)
(/ boltdia 2)
) ; end polar
) ; end setq
(setq tpbolttpptl
(polar
tpbolttpptr
pi
(- flgc flgf)
) ; end polar
) ; end setq
(command "_line"
tpbolttpptr
tpbolttpptl ""
) ; end line
(setq a17 (entlast))
(setq tpboltbtptr
(polar
(polar
tpboltclr
pi
1.6
) ; end polar
(/ (* pi 3) 2)
(/ boltdia 2)
) ; end polar
) ; end setq
(setq tpboltbtptl
(polar
tpboltbtptr
pi
(- flgc flgf)
) ; end polar
) ; end setq
(command "_line"
tpboltbtptr
tpboltbtptl ""
) ; end line
(setq a18 (entlast))
(setq btbolttpptr
(polar
(polar
btboltclr
pi
1.6
) ; end polar
(/ pi 2)
(/ boltdia 2)
) ; end polar
) ; end setq
(setq btbolttpptl
(polar
btbolttpptr
pi
(- flgc flgf)
) ; end polar
) ; end setq
(command "_line"
btbolttpptr
btbolttpptl ""
) ; end line
(setq a19 (entlast))
(setq btboltbtptr
(polar
(polar
btboltclr
pi
1.6
) ; end polar
(/ (* pi 3) 2)
(/ boltdia 2)
) ; end polar
) ; end setq
(setq btboltbtptl
(polar
btboltbtptr
pi
(- flgc flgf)
) ; end polar
) ; end setq
(command "_line"
btboltbtptr
btboltbtptl ""
) ; end line
(setq a20 (entlast))
(setvar "clayer" "5")
(setq mainclr
(polar
flgept1
0
20
) ; end polar
) ; end setq
(setq maincll
(polar
flgept1
pi
(+ flgy 20)
) ; end polar
) ; end setq
(command "_line"
mainclr
maincll ""
) ; end line
(setq a21 (entlast))
(command "regenall")
) ; end flange elevation draw program

; ***** Flange Elevation Fillet *****

(defun flangeelevfillet ()
(setvar "filletrad" fillrad)
(vl-cmdf "_.fillet"
(setq b1
(list a6
(polar
flgotppt
pi
fillrad
) ; end polar
) ; end list
) ; end setq
(setq b2
(list a8
(polar
flgoltppt
(/ (* pi 3) 2)
fillrad
) ; end polar
) ; end list
) ; end setq
) ; end fillet
(setq f1 (entlast))
(vl-cmdf "_.fillet"
(setq b3
(list
a7
(polar
flgobtpt
pi
fillrad
) ; end polar
) ; end list
) ; end setq
(setq b4
(list
a9
(polar
flgolbtpt
(/ pi 2)
fillrad
) ; end polar
) ; end list
) ; end setq
) ; end fillet
(setq f2 (entlast))
(vl-cmdf "_.fillet"
(setq b5
(list
a8
(polar
flgoltppt
(/ (* pi 3) 2)
fillrad
) ; end polar
) ; end list
) ; end setq
(setq b6
(list
a10
(polar
flgxrtppt
pi
fillrad
) ; end polar
) ; end list
) ; end setq
) ; end fillet
(setq f3 (entlast))
(vl-cmdf "_.fillet"
(setq b7
(list
a9
(polar
flgolbtpt
(/ pi 2)
fillrad
) ; end polar
) ; end list
) ; end setq
(setq b8
(list
a11
(polar
flgxrbtpt
pi
fillrad
) ; end polar
) ; end list
) ; end setq
) ; end fillet
(setq f4 (entlast))
(vl-cmdf "_.fillet"
(setq b9
(list
a10
(polar
flgxrtppt
pi
fillrad
) ; end polar
) ; end list
) ; end setq
(setq b10
(list
a12
(polar
flgxtppt
(/ (* pi 3) 2)
fillrad
) ; end polar
) ; end list
) ; end setq
) ; end fillet
(setq f5 (entlast))
(vl-cmdf "_.fillet"
(setq b11
(list
a11
(polar
flgxrbtpt
pi
fillrad
) ; end polar
) ; end list
) ; end setq
(setq b12
(list
a12
(polar
flgxbtpt
(/ pi 2)
fillrad
) ; end polar
) ; end list
) ; end setq
) ; end fillet
(setq f6 (entlast))
(command "regenall")
)

; ***** Flange Adjustment *****

(defun flgadj (/ cFlag flgans)
(while(not cFlag)
(initget "Duplicate Move Rotate")
(setq flgans (getkword "\nAdjustment? [Duplicate/Move/Rotate]: "))
(cond
(
(= flgans "Duplicate")
(command "_copy"
a1
a2
a3
a4
a5
a6
a7
a8
a9
a10
a11
a12
a13
a14
a15
a16
a17
a18
a19
a20
a21
f1
f2
f3
f4
f5
f6 ""
(polar
flgept1
pi
(/ flgy 2)
) ; end polar
pause
) ; end copy
) ; end condition #1
(
(= flgans "Move")
(prompt "\nSelect Base Point and Move Flange")
(command "_move"
a1
a2
a3
a4
a5
a6
a7
a8
a9
a10
a11
a12
a13
a14
a15
a16
a17
a18
a19
a20
a21
f1
f2
f3
f4
f5
f6 ""
pause
pause
) ; end move
) ; end condition #2
(
(= flgans "Rotate")
(command "_rotate"
a1
a2
a3
a4
a5
a6
a7
a8
a9
a10
a11
a12
a13
a14
a15
a16
a17
a18
a19
a20
a21
f1
f2
f3
f4
f5
f6 ""
pause
pause
) ; end rotate
) ; end condition #3
(
T
(prompt "\nExiting Adjustment Menu...")
(setq cFlag T)
) ; end condition #3
) ; end cond
) ; end while
(princ)
) ; end of program

; ***********************************************************************************
; ***** Flange Main Program ******************************************************************* FLANGE PROGRAM
; ***********************************************************************************

(defun flangemain ()
(setq oldlayers (getvar "clayer"))
(setq oldsnaps (getvar "osmode"))
(initget 1 "Plan Elevation")
(setq progdec3 (getkword "\nSelect View [Plan/Elevation]"))
(if
(= progdec3 "Plan")
(progn
(userflangevalues)
(flangevariablesetter)
(setvar "osmode" 0)
(flangedraw)
) ; end progn
) ; end if
(if
(= progdec3 "Elevation")
(progn
(userflangeelevvalues)
(flangeelevvariablesetter)
(setvar "osmode" 0)
(flangeelevdraw)
(flangeelevfillet)
(setvar "osmode" oldsnaps)
(flgadj)
) ; end progn
) ; end if
(setvar "osmode" oldsnaps)
(setvar "clayer" oldlayers)
(princ)
) ; end flange main program

; **********************************************************************************************************************************
; *************************** END OF FLANGE PROGRAM ********************************************************************************
; **********************************************************************************************************************************

; ***** Pipe Elevation User Input *****

(defun userpipevalues ()
(prompt "\nDraw Pipe Centre Line: ")
(command "_line"
pause
pause ""
)
(setq pipelin (entlast))
(initget 1 "50 80 100 150 200 250")
(setq pipesizeelev (getkword "\nSelect Pipe Size [50/80/100/150/200/250]: "))
)

; ***** Pipe Plan User Input *****

(defun userpipevaluesplan ()
(setq pipeinspt (getpoint "\nSelect Point for Pipe Insertion"))
(initget 1 "50 80 100 150 200 250")
(setq pipesize (getkword "\nSelect Pipe Size [50/80/100/150/200/250]: "))
)

; ***** Pipe Elevation Variable Setter *****

(defun pipevariablesetter ()
(if ; *** 50NB PIPE ***
(= pipesizeelev "50")
(progn
(setq
pipeod 60.3
pipeid 52.48
) ; end setq
) ; end progn
) ; end if
(if ; *** 80NB PIPE ***
(= pipesizeelev "80")
(progn
(setq
pipeod 88.9
pipeid 77.92
) ; end setq
) ; end progn
) ; end if
(if ; *** 100NB PIPE ***
(= pipesizeelev "100")
(progn
(setq
pipeod 114.3
pipeid 102.26
) ; end setq
) ; end progn
) ; end if
(if ; *** 150NB PIPE ***
(= pipesizeelev "150")
(progn
(setq
pipeod 168.3
pipeid 154.08
) ; end setq
) ; end progn
) ; end if
(if ; *** 200NB PIPE ***
(= pipesizeelev "200")
(progn
(setq
pipeod 219.1
pipeid 202.74
) ; end setq
) ; end progn
) ; end if
(if ; *** 250NB PIPE ***
(= pipesizeelev "250")
(progn
(setq
pipeod 273.1
pipeid 254.56
) ; end setq
) ; end progn
) ; end if
) ; end program

; ***** Pipe Plan Variable Setter *****

(defun pipeplanvariablesetter ()
(if ; *** 50NB PIPE ***
(= pipesize "50")
(progn
(setq
pipeod 60.3
pipeid 52.48
) ; end setq
) ; end progn
) ; end if
(if ; *** 80NB PIPE ***
(= pipesize "80")
(progn
(setq
pipeod 88.9
pipeid 77.92
) ; end setq
) ; end progn
) ; end if
(if ; *** 100NB PIPE ***
(= pipesize "100")
(progn
(setq
pipeod 114.3
pipeid 102.26
) ; end setq
) ; end progn
) ; end if
(if ; *** 150NB PIPE ***
(= pipesize "150")
(progn
(setq
pipeod 168.3
pipeid 154.08
) ; end setq
) ; end progn
) ; end if
(if ; *** 200NB PIPE ***
(= pipesize "200")
(progn
(setq
pipeod 219.1
pipeid 202.74
) ; end setq
) ; end progn
) ; end if
(if ; *** 250NB PIPE ***
(= pipesize "250")
(progn
(setq
pipeod 273.1
pipeid 254.56
) ; end setq
) ; end progn
) ; end if
) ; end program

; ***** Pipe Elevation Draw *****

(defun pipeelevdraw ()
(setq pipent (entget pipelin))
(setq pipstpt
(cdr
(assoc 10 pipent)
) ; end cdr
) ; end setq
(setq pipenpt
(cdr
(assoc 11 pipent)
) ; end cdr
) ; end setq
(setq pipang (angle pipstpt pipenpt))
(setq pipidstpt
(polar
pipstpt
(+ pipang (/ pi 2))
(/ pipeid 2)
) ; end polar
) ; end setq
(setq pipidenpt
(polar
pipenpt
(+ pipang (/ pi 2))
(/ pipeid 2)
) ; end polar
) ; end setq
(setvar "clayer" "1")
(command "_line"
pipidstpt
pipidenpt
""
) ; end line
(setq pipeidtopl (entlast))
(setq pipodstpt
(polar
pipstpt
(+ pipang (/ pi 2))
(/ pipeod 2)
) ; end polar
) ; end setq
(setq pipodenpt
(polar
pipenpt
(+ pipang (/ pi 2))
(/ pipeod 2)
) ; end polar
) ; end setq
(setvar "clayer" "3")
(command "_line"
pipodstpt
pipodenpt
""
) ; end line
(setq pipeodtopl (entlast))
(setq pipidbstpt
(polar
pipstpt
(- pipang (/ pi 2))
(/ pipeid 2)
) ; end polar
) ; end setq
(setq pipidbenpt
(polar
pipenpt
(- pipang (/ pi 2))
(/ pipeid 2)
) ; end polar
) ; end setq
(setvar "clayer" "1")
(command "_line"
pipidbstpt
pipidbenpt
""
) ; end line
(setq pipeidbotl (entlast))
(setq pipodbstpt
(polar
pipstpt
(- pipang (/ pi 2))
(/ pipeod 2)
) ; end polar
) ; end setq
(setq pipodbenpt
(polar
pipenpt
(- pipang (/ pi 2))
(/ pipeod 2)
) ; end polar
) ; end setq
(setvar "clayer" "3")
(command "_line"
pipodbstpt
pipodbenpt
""
) ; end line
(setq pipeodbotl (entlast))
(setvar "clayer" "5")
(command "_line"
pipstpt
pipenpt
""
) ; end line
(entdel pipelin)
(command "regenall")
) ; end pipe draw

; ***** Pipe Plan Draw *****

(defun pipeplandraw ()
(setvar "clayer" "1")
(command "_circle"
pipeinspt
"D"
pipeid
) ; end circle
(setvar "clayer" "3")
(command "_circle"
pipeinspt
"D"
pipeod
) ; end circle
(setvar "clayer" "5")
(setq pipecltppt
(polar
pipeinspt
(/ pi 2)
(+ (/ pipeod 2) 30)
) ; end polar
) ; end setq
(setq pipeclbtpt
(polar
pipeinspt
(/ (* pi 3) 2)
(+ (/ pipeod 2) 30)
) ; end polar
) ; end setq
(command "_line"
pipecltppt
pipeclbtpt ""
) ; end line
(setq pipeclltpt
(polar
pipeinspt
pi
(+ (/ pipeod 2) 30)
) ; end polar
) ; end setq
(setq pipeclrtpt
(polar
pipeinspt
0
(+ (/ pipeod 2) 30)
) ; end polar
) ; end setq
(command "_line"
pipeclltpt
pipeclrtpt ""
) ; end line
(command "regenall")
) ; end pipe plan draw program

; **************************************************************************************
; ***** Pipe Main Program ************************************************************************* PIPE PROGRAM
; **************************************************************************************

(defun pipemain ()
(setq oldlayers1 (getvar "clayer"))
(setq oldsnaps1 (getvar "osmode"))
(initget 1 "Plan Elevation")
(setq progdec2 (getkword "\nSelect View [Plan/Elevation]"))
(if
(= progdec2 "Elevation")
(progn
(userpipevalues)
(pipevariablesetter)
(setvar "osmode" 0)
(pipeelevdraw)
) ; end progn
) ; end if
(if
(= progdec2 "Plan")
(progn
(userpipevaluesplan)
(pipeplanvariablesetter)
(setvar "osmode" 0)
(pipeplandraw)
) ; end progn
) ; end if
(setvar "osmode" oldsnaps1)
(setvar "clayer" oldlayers1)
(princ)
) ; end pipe main program

; ***********************************************************************************************************************************
; *************************** END OF PIPE PROGRAM ***********************************************************************************
; ***********************************************************************************************************************************

; ***** Elbow User Input *****

(defun elbowuser ()
(setq elbpt1 (getpoint "\nSelect Point for Elbow: "))
(initget 1 "50 80 100 150 200 250")
(setq elbsize (getkword "\nSelect Elbow Pipe Size [50/80/100/150/200/250]: "))
(initget 1 "Long Short 5D")
(setq elbrad (getkword "\nSelect Elbow Radius [Long/Short/5D]"))
(setq elbang (getreal "\nEnter Elbow Angle (1-180)"))
) ; end elbow user input program

; ***** Elbow Varible Setter *****

(defun elbowvariablesetter ()
(if ; *** 50NB ELBOW ***
(= elbsize "50")
(progn
(setq
pipeod 60.3
pipeid 52.48
) ; end setq
) ; end progn
) ; end if
(if ; *** 80NB ELBOW ***
(= elbsize "80")
(progn
(setq
pipeod 88.9
pipeid 77.92
) ; end setq
) ; end progn
) ; end if
(if ; *** 100NB ELBOW ***
(= elbsize "100")
(progn
(setq
pipeod 114.3
pipeid 102.26
) ; end setq
) ; end progn
) ; end if
(if ; *** 150NB ELBOW ***
(= elbsize "150")
(progn
(setq
pipeod 168.3
pipeid 154.08
) ; end setq
) ; end progn
) ; end if
(if ; *** 200NB ELBOW ***
(= elbsize "200")
(progn
(setq
pipeod 219.1
pipeid 202.74
) ; end setq
) ; end progn
) ; end if
(if ; *** 250NB ELBOW ***
(= elbsize "250")
(progn
(setq
pipeod 273.1
pipeid 254.56
) ; end setq
) ; end progn
) ; end if
) ; end program

; ***** Elbow Draw *****

(defun elbowdraw ()
(setq elbsizeint (atof elbsize))
(if
(= elbrad "Long")
(setq elbcl (* elbsizeint 1.5))
) ; end if
(if
(= elbrad "Short")
(setq elbcl elbsizeint)
) ; end if
(if
(= elbrad "5D")
(setq elbcl (* elbsizeint 5))
) ; end if
(setvar "clayer" "5")
(command "_arc"
"C"
elbpt1
(polar
elbpt1
0
elbcl
) ; end polar
"A"
elbang
) ; end arc
(setq circcl (entlast))
(setvar "clayer" "3")
(command "_arc"
"C"
elbpt1
(polar
elbpt1
0
(- elbcl (/ pipeod 2))
) ; end polar
"A"
elbang
) ; end arc
(setq circod1 (entlast))
(command "_arc"
"C"
elbpt1
(polar
elbpt1
0
(+ elbcl (/ pipeod 2))
) ; end polar
"A"
elbang
) ; end arc
(setq circod2 (entlast))
(setvar "clayer" "1")
(command "_arc"
"C"
elbpt1
(polar
elbpt1
0
(- elbcl (/ pipeid 2))
) ; end polar
"A"
elbang
) ; end arc
(setq circid1 (entlast))
(command "_arc"
"C"
elbpt1
(polar
elbpt1
0
(+ elbcl (/ pipeid 2))
) ; end polar
"A"
elbang
) ; end arc
(setq circid2 (entlast))
(setvar "clayer" "3")
(command "_line"
(polar
elbpt1
(* pi (/ elbang 180.0))
(- elbcl (/ pipeod 2))
) ; end polar
(polar
elbpt1
(* pi (/ elbang 180.0))
(+ elbcl (/ pipeod 2))
) ; end polar
""
) ; end line
(setq elbline3 (entlast))
(command "_line"
(polar
elbpt1
0
(- elbcl (/ pipeod 2))
) ; end polar
(polar
elbpt1
0
(+ elbcl (/ pipeod 2))
) ; end polar
""
) ; end line
(setq elbline4 (entlast))
(command "regenall")
) ; end elbow draw program

; ***** Elbow Adjustments *****

(defun elbadj (/ cFlag elbadjans)
(while
(not cFlag)
(initget "Duplicate Move Rotate")
(setq elbadjans (getkword "\nAdjustment? [Duplicate/Move/Rotate]: "))
(cond
(
(= elbadjans "Duplicate")
(command "_copy"
circcl
circod1
circod2
circid1
circid2
elbline3
elbline4 ""
elbpt1
pause
) ; end copy
); end condition #1
(
(= elbadjans "Move")
(command "_move"
circcl
circod1
circod2
circid1
circid2
elbline3
elbline4 ""
pause
pause
) ; end move
); end condition #2
(
(= elbadjans "Rotate")
(command "_rotate"
circcl
circod1
circod2
circid1
circid2
elbline3
elbline4 ""
pause
pause
) ; end rotate
); end condition #3
(
T
(prompt "\nExiting Adjustment Menu...")
(setq cFlag T)
); end condition #3
); end cond
); end while
(princ)
); end of program

; ***** Elbow Plan Programs *****
; *******************************

; ***** Elbow Plan User Input *****

(defun elbowplanuser ()
(setq elbplanpt1 (getpoint "\nSelect Point for Elbow: "))
(initget 1 "50 80 100 150 200 250")
(setq elbplansize (getkword "\nSelect Elbow Pipe Size [50/80/100/150/200/250]: "))
(initget 1 "Long Short 5D")
(setq elbplanrad (getkword "\nSelect Elbow Radius [Long/Short/5D]"))
(setq elbplanang2 (getreal "\nEnter Elbow Angle (1-180)"))
) ; end elbow user input program

; ***** Elbow Plan Variable Setter *****

(defun elbowplanvariablesetter ()
(if ; *** 50NB ELBOW ***
(= elbplansize "50")
(progn
(setq
pipeod 60.3
pipeid 52.48
) ; end setq
) ; end progn
) ; end if
(if ; *** 80NB ELBOW ***
(= elbplansize "80")
(progn
(setq
pipeod 88.9
pipeid 77.92
) ; end setq
) ; end progn
) ; end if
(if ; *** 100NB ELBOW ***
(= elbplansize "100")
(progn
(setq
pipeod 114.3
pipeid 102.26
) ; end setq
) ; end progn
) ; end if
(if ; *** 150NB ELBOW ***
(= elbplansize "150")
(progn
(setq
pipeod 168.3
pipeid 154.08
) ; end setq
) ; end progn
) ; end if
(if ; *** 200NB ELBOW ***
(= elbplansize "200")
(progn
(setq
pipeod 219.1
pipeid 202.74
) ; end setq
) ; end progn
) ; end if
(if ; *** 250NB ELBOW ***
(= elbplansize "250")
(progn
(setq
pipeod 273.1
pipeid 254.56
) ; end setq
) ; end progn
) ; end if
) ; end program

; ***** Elbow Plan Draw *****

(defun elbowplandraw ()
(setq elbplansizeint (atof elbplansize))
(if
(= elbplanrad "Long")
(setq elbplancl (* elbplansizeint 1.5))
) ; end if
(if
(= elbplanrad "Short")
(setq elbplancl elbplansizeint)
) ; end if
(if
(= elbplanrad "5D")
(setq elbplancl (* elbplansizeint 5))
) ; end if
(setvar "clayer" "3")
(command "_arc"
"C"
elbplanpt1
(polar
elbplanpt1
(/ pi 2)
(/ pipeod 2)
) ; end polar
"A"
"-180"
) ; end arc
(setvar "clayer" "1")
(command "_arc"
"C"
elbplanpt1
(polar
elbplanpt1
(/ pi 2)
(/ pipeod 2)
) ; end polar
"A"
"180"
) ; end arc
(command "_circle"
elbplanpt1
(/ pipeid 2)
) ; end circle

; **************************************************** Angles less than 180.0 (not = to 90.0)

(if
(and
(/= elbplanang2 90.0)
( elbplanang2 180.0)
(/= elbplanang2 270.0)
) ; end and
(progn
(setq lpcent
(polar
elbplanpt1
pi
(* elbplancl 2)
) ; end polar
) ; end setq
(setvar "clayer" "3")
(command "_arc"
"C"
lpcent
(polar
lpcent
(/ pi 2)
(/ pipeod 2)
) ; end polar
"A"
"180.0"
) ; end arc
(setvar "clayer" "1")
(command "_arc"
"C"
lpcent
(polar
lpcent
(/ pi 2)
(/ pipeod 2)
) ; end polar
"A"
"-180.0"
) ; end arc
(command "_circle"
lpcent
(/ pipeid 2)
) ; end circle
(command "_line"
(polar
lpcent
(/ (* pi 3) 2)
(/ pipeid 2)
) ; end polar
(polar
elbplanpt1
(/ (* pi 3) 2)
(/ pipeid 2)
) ; end polar
""
) ; end line
(command "_line"
(polar
lpcent
(/ pi 2)
(/ pipeid 2)
) ; end polar
(polar
elbplanpt1
(/ pi 2)
(/ pipeid 2)
) ; end polar
""
) ; end line
(setvar "clayer" "3")
(command "_line"
(polar
lpcent
(/ (* pi 3) 2)
(/ pipeod 2)
) ; end polar
(polar
elbplanpt1
(/ (* pi 3) 2)
(/ pipeod 2)
) ; end polar
""
) ; end line
(command "_line"
(polar
lpcent
(/ pi 2)
(/ pipeod 2)
) ; end polar
(polar
elbplanpt1
(/ pi 2)
(/ pipeod 2)
) ; end polar
""
) ; end line
(setvar "clayer" "5")
(command "_line"
(polar
elbplanpt1
(/ (* pi 3) 2)
(+ (/ pipeod 2) 20)
) ; end polar
(polar
elbplanpt1
(/ pi 2)
(+ (/ pipeod 2) 20)
) ; end polar
""
) ; end line
(command "_line"
(polar
lpcent
(/ (* pi 3) 2)
(+ (/ pipeod 2) 20)
) ; end polar
(polar
lpcent
(/ pi 2)
(+ (/ pipeod 2) 20)
) ; end polar
""
) ; end line
(command "_line"
(polar
elbplanpt1
0
(+ (/ pipeod 2) 20)
) ; end polar
(polar
lpcent
pi
(+ (/ pipeod 2) 20)
) ; end polar
""
) ; end line
(setq elbplanang (* pi (/ elbplanang2 180.0)))
(setvar "clayer" "1")
(setq ellcentdist
(*
(* elbplancl (sin elbplanang))
(/
(sin (/ elbplanang 2))
(cos (/ elbplanang 2))
) ; end division
) ; end multiplication
) ; end setq
(setq ellcentpt
(polar
elbplanpt1
pi
ellcentdist
) ; end polar
) ; end setq
(command "_ellipse"
"C"
ellcentpt
(polar
ellcentpt
(/ pi 2)
(/ pipeid 2)
) ; end polar
(polar
ellcentpt
0
(*
(/ pipeid 2)
(cos elbplanang)
) ; end multiplication
) ; end polar
) ; end ellipse
(command "_ellipse"
"C"
ellcentpt
(polar
ellcentpt
(/ pi 2)
(/ pipeod 2)
) ; end polar
(polar
ellcentpt
0
(*
(/ pipeod 2)
(cos elbplanang)
) ; end multiplication
) ; end polar
) ; end ellipse
) ; end progn
) ; end if

; ************************************************************** Angles equal to 270.0

(if
(= elbplanang2 270.0)
(progn
(setq lpcent
(polar
elbplanpt1
pi
(* elbplancl 2)
) ; end polar
) ; end setq
(setvar "clayer" "3")
(command "_arc"
"C"
lpcent
(polar
lpcent
(/ pi 2)
(/ pipeod 2)
) ; end polar
"A"
"180.0"
) ; end arc
(setvar "clayer" "1")
(command "_arc"
"C"
lpcent
(polar
lpcent
(/ pi 2)
(/ pipeod 2)
) ; end polar
"A"
"-180.0"
) ; end arc
(command "_circle"
lpcent
(/ pipeid 2)
) ; end circle
(command "_line"
(polar
lpcent
(/ (* pi 3) 2)
(/ pipeid 2)
) ; end polar
(polar
elbplanpt1
(/ (* pi 3) 2)
(/ pipeid 2)
) ; end polar
""
) ; end line
(command "_line"
(polar
lpcent
(/ pi 2)
(/ pipeid 2)
) ; end polar
(polar
elbplanpt1
(/ pi 2)
(/ pipeid 2)
) ; end polar
""
) ; end line
(setvar "clayer" "3")
(command "_line"
(polar
lpcent
(/ (* pi 3) 2)
(/ pipeod 2)
) ; end polar
(polar
elbplanpt1
(/ (* pi 3) 2)
(/ pipeod 2)
) ; end polar
""
) ; end line
(command "_line"
(polar
lpcent
(/ pi 2)
(/ pipeod 2)
) ; end polar
(polar
elbplanpt1
(/ pi 2)
(/ pipeod 2)
) ; end polar
""
) ; end line
(setvar "clayer" "5")
(command "_line"
(polar
elbplanpt1
(/ (* pi 3) 2)
(+ (/ pipeod 2) 20)
) ; end polar
(polar
elbplanpt1
(/ pi 2)
(+ (/ pipeod 2) 20)
) ; end polar
""
) ; end line
(command "_line"
(polar
lpcent
(/ (* pi 3) 2)
(+ (/ pipeod 2) 20)
) ; end polar
(polar
lpcent
(/ pi 2)
(+ (/ pipeod 2) 20)
) ; end polar
""
) ; end line
(command "_line"
(polar
elbplanpt1
0
(+ (/ pipeod 2) 20)
) ; end polar
(polar
lpcent
pi
(+ (/ pipeod 2) 20)
) ; end polar
""
) ; end line
(setvar "clayer" "1")
(command "_line"
(setq mpt1
(polar
(polar
elbplanpt1
(/ (* pi 3) 2)
(/ pipeod 2)
) ; end polar
pi
elbplancl
) ; end polar
) ; end setq
(polar
mpt1
(/ pi 2)
pipeod
) ; end polar
""
) ; end line
) ; end progn
) ; end if
) ; end program

; *************************************************************************************
; ***** Elbow Main Program ********************************************************************** ELBOW PROGRAM
; *************************************************************************************

(defun elbowmain ()
(setq oldlayers2 (getvar "clayer"))
(setq oldsnaps2 (getvar "osmode"))
(initget 1 "Plan Elevation")
(setq elbprogdec (getkword "\nSelect View [Plan/Elevation]"))
(if
(= elbprogdec "Elevation")
(progn
(elbowuser)
(elbowvariablesetter)
(setvar "osmode" 0)
(elbowdraw)
(setvar "osmode" oldsnaps2)
(setvar "clayer" oldlayers2)
(elbadj)
) ; end progn
) ; end if
(if
(= elbprogdec "Plan")
(progn
(elbowplanuser)
(elbowplanvariablesetter)
(setvar "osmode" 0)
(elbowplandraw)
(setvar "osmode" oldsnaps2)
(setvar "clayer" oldlayers2)
) ; end progn
) ; end if
(princ)
) ; end elbow main program

; ***********************************************************************************************************************************
; *************************** END OF ELBOW PROGRAM **********************************************************************************
; ***********************************************************************************************************************************

; ==============================================================================
; ************************** **************************
; ************************** Tee Elevation User Input **************************
; ************************** **************************
; ==============================================================================

(defun userteevalues ()
(setq teept1 (getpoint "\nSelect Point for Equal Tee: "))
(initget 1 "50 80 100 150 200 250")
(setq teesize (getkword "\nSelect Equal Tee Size [50/80/100/150/200/250]: "))
) ; end user input

; =========================================================================
; ************************** **************************
; ************************** Tee Plan User Input **************************
; ************************** **************************
; =========================================================================

(defun userteepvalues ()
(setq pteept1 (getpoint "\nSelect Point for Equal Tee: "))
(initget 1 "50 80 100 150 200 250")
(setq pteesize (getkword "\nSelect Equal Tee Size [50/80/100/150/200/250]: "))
) ; end user input

; ===================================================================================
; ************************** **************************
; ************************** Tee Elevation Variable Setter **************************
; ************************** **************************
; ===================================================================================

(defun teevariablesetter ()
(if ; *** 50NB TEE ***
(= teesize "50")
(progn
(setq
pipeod 60.3
pipeid 52.48
tcm 64.0
) ; end setq
) ; end progn
) ; end if
(if ; *** 80NB TEE ***
(= teesize "80")
(progn
(setq
pipeod 88.9
pipeid 77.92
tcm 86.0
) ; end setq
) ; end progn
) ; end if
(if ; *** 100NB TEE ***
(= teesize "100")
(progn
(setq
pipeod 114.3
pipeid 102.26
tcm 105.0
) ; end setq
) ; end progn
) ; end if
(if ; *** 150NB TEE ***
(= teesize "150")
(progn
(setq
pipeod 168.3
pipeid 154.08
tcm 143.0
) ; end setq
) ; end progn
) ; end if
(if ; *** 200NB TEE ***
(= teesize "200")
(progn
(setq
pipeod 219.1
pipeid 202.74
tcm 178.0
) ; end setq
) ; end progn
) ; end if
(if ; *** 250NB TEE ***
(= teesize "250")
(progn
(setq
pipeod 273.1
pipeid 254.56
tcm 216.0
) ; end setq
) ; end progn
) ; end if
) ; end program

; ==============================================================================
; ************************** **************************
; ************************** Tee Plan Variable Setter **************************
; ************************** **************************
; ==============================================================================

(defun pteevariablesetter ()
(if ; *** 50NB TEE ***
(= pteesize "50")
(progn
(setq
pipeod 60.3
pipeid 52.48
tcm 64.0
) ; end setq
) ; end progn
) ; end if
(if ; *** 80NB TEE ***
(= pteesize "80")
(progn
(setq
pipeod 88.9
pipeid 77.92
tcm 86.0
) ; end setq
) ; end progn
) ; end if
(if ; *** 100NB TEE ***
(= pteesize "100")
(progn
(setq
pipeod 114.3
pipeid 102.26
tcm 105.0
) ; end setq
) ; end progn
) ; end if
(if ; *** 150NB TEE ***
(= pteesize "150")
(progn
(setq
pipeod 168.3
pipeid 154.08
tcm 143.0
) ; end setq
) ; end progn
) ; end if
(if ; *** 200NB TEE ***
(= pteesize "200")
(progn
(setq
pipeod 219.1
pipeid 202.74
tcm 178.0
) ; end setq
) ; end progn
) ; end if
(if ; *** 250NB TEE ***
(= pteesize "250")
(progn
(setq
pipeod 273.1
pipeid 254.56
tcm 216.0
) ; end setq
) ; end progn
) ; end if
) ; end program

; ======================================================================
; ************************** **************************
; ************************** Tee Draw Program **************************
; ************************** **************************
; ======================================================================

(defun teedraw ()
(setq teecircl
(polar
teept1
pi
tcm
) ; end polar
) ; end setq
(setq teecircr
(polar
teept1
0
tcm
) ; end polar
) ;end setq
(setvar "clayer" "5")
(command "_arc"
"C"
teecircl
teept1
"A"
"-90"
) ; end arc
(setq te1 (entlast))
(command "_arc"
"C"
teecircr
teept1
"A"
"90"
) ; end arc
(setq te2 (entlast))
(command "_line"
(polar
teecircl
(/ (* pi 3) 2)
tcm
) ; end polar
(polar
teecircr
(/ (* pi 3) 2)
tcm
) ; end polar
""
) ; end line
(setq te3 (entlast))
(setvar "clayer" "3")
(command "_arc"
"C"
teecircl
(polar
teecircl
0
(- tcm (/ pipeod 2))
) ; end polar
"A"
"-90"
) ; end arc
(setq te4 (entlast))
(command "_arc"
"C"
teecircr
(polar
teecircr
pi
(- tcm (/ pipeod 2))
) ; end polar
"A"
"90"
) ; end arc
(setq te5 (entlast))
(setq teebaseodl
(polar
teecircl
(/ (* pi 3) 2)
(+ tcm (/ pipeod 2))
) ; end polar
) ; end setq
(setq teebaseodr
(polar
teecircr
(/ (* pi 3) 2)
(+ tcm (/ pipeod 2))
) ; end polar
) ; end setq
(command "_line"
teebaseodl
teebaseodr ""
) ; end line
(setq te6 (entlast))
(command "_line"
(polar
teecircl
(/ (* pi 3) 2)
(- tcm (/ pipeod 2))
) ; end polar
(polar
teecircl
(/ (* pi 3) 2)
(+ tcm (/ pipeod 2))
) ; end polar
""
) ; end line
(setq te7 (entlast))
(command "_line"
(polar
teecircr
(/ (* pi 3) 2)
(- tcm (/ pipeod 2))
) ; end polar
(polar
teecircr
(/ (* pi 3) 2)
(+ tcm (/ pipeod 2))
) ; end polar
""
) ; end line
(setq te8 (entlast))
(command "_line"
(polar
teecircl
0
(- tcm (/ pipeod 2))
) ; end polar
(polar
teecircl
0
(+ tcm (/ pipeod 2))
) ; end polar
""
) ; end line
(setq te9 (entlast))
(setvar "clayer" "1")
(command "_arc"
"C"
teecircl
(polar
teecircl
0
(- tcm (/ pipeid 2))
) ; end polar
"A"
"-90"
) ; end arc
(setq te10 (entlast))
(command "_arc"
"C"
teecircr
(polar
teecircr
pi
(- tcm (/ pipeid 2))
) ; end polar
"A"
"90"
) ; end arc
(setq te11 (entlast))
(command "_line"
(polar
teecircl
(/ (* pi 3) 2)
(+ tcm (/ pipeid 2))
) ; end polar
(polar
teecircr
(/ (* pi 3) 2)
(+ tcm (/ pipeid 2))
) ; end polar
""
) ; end line
(setq te12 (entlast))
(command "regenall")
)

; ===============================================================================
; ************************** **************************
; ************************** Tee Elevation Adjustments **************************
; ************************** **************************
; ===============================================================================

(defun teeadj (/ cFlag teeadjans)
(while
(not cFlag)
(initget "Duplicate Move Rotate")
(setq teeadjans(getkword "\nAdjustment? [Duplicate/Move/Rotate]: "))
(cond
(
(= teeadjans "Duplicate")
(command "_copy"
te1
te2
te3
te4
te5
te6
te7
te8
te9
te10
te11
te12 ""
(polar
teept1
(/ (* pi 3) 2)
tcm
) ; end polar
pause
) ; end copy
); end condition #1
(
(= teeadjans "Move")
(command "_move"
te1
te2
te3
te4
te5
te6
te7
te8
te9
te10
te11
te12 ""
pause
pause
) ; end move
); end condition #2
(
(= teeadjans "Rotate")
(command "_rotate"
te1
te2
te3
te4
te5
te6
te7
te8
te9
te10
te11
te12 ""
pause
pause
) ; end rotate
); end condition #3
(
T
(prompt "Exiting Adjustment Menu...")
(setq cFlag T)
); end condition #3
); end cond
); end while
(princ)
); end of program

; ===================================================================
; ************************** **************************
; ************************** Tee Plan Draw **************************
; ************************** **************************
; ===================================================================

(defun teepdraw ()
(setvar "clayer" "1")
(command "_circle"
pteept1
"D"
pipeid
) ; end circle
(setq teep1 (entlast))
(setq Tpidt
(polar
pteept1
(/ pi 2)
(/ pipeid 2)
) ; end polar
) ; end setq
(setq Tpidb
(polar
pteept1
(/ (* pi 3) 2)
(/ pipeid 2)
) ; end polar
) ; end setq
(command "_line"
(polar
Tpidt
pi
tcm
) ; end polar
(polar
Tpidt
0
tcm
) ; end polar
""
) ; end line
(setq teep2 (entlast))
(command "_line"
(polar
Tpidb
pi
tcm
) ; end polar
(polar
Tpidb
0
tcm
) ; end polar
""
) ; end line
(setq teep3 (entlast))
(setvar "clayer" "3")
(command "_circle"
pteept1
"D"
pipeod
) ; end circle
(setq teep4 (entlast))
(setq Tpodt
(polar
pteept1
(/ pi 2)
(/ pipeod 2)
) ; end polar
) ; end setq
(setq Tpodb
(polar
pteept1
(/ (* pi 3) 2)
(/ pipeod 2)
) ; end polar
) ; end setq
(command "_line"
(polar
Tpodt
pi
tcm
) ; end polar
(polar
Tpodt
0
tcm
) ; end polar
""
) ; end line
(setq teep5 (entlast))
(command "_line"
(polar
Tpodb
pi
tcm
) ; end polar
(polar
Tpodb
0
tcm
) ; end polar
""
) ; end line
(setq teep6 (entlast))
(command "_line"
(polar
Tpodt
pi
tcm
) ; end polar
(polar
Tpodb
pi
tcm
) ; end polar
""
) ; end line
(setq teep7 (entlast))
(command "_line"
(polar
Tpodt
0
tcm
) ; end polar
(polar
Tpodb
0
tcm
) ; end polar
""
) ; end line
(setq teep8 (entlast))
(setvar "clayer" "5")
(command "_line"
(polar
pteept1
pi
tcm
) ; end polar
(polar
pteept1
0
tcm
) ; end polar
""
) ; end line
(setq teep9 (entlast))
(command "_line"
(polar
pteept1
(/ pi 2)
(+ (/ pipeod 2) 20)
) ; end polar
(polar
pteept1
(/ (* pi 3) 2)
(+ (/ pipeod 2) 20)
) ; end polar
""
) ; end line
(setq teep10 (entlast))
(command "regenall")
) ; end program

; ========================================================================
; ************************** ************************
; ************************** Tee Plan Adjustments ************************
; ************************** ************************
; ========================================================================

(defun pteeadj (/ cFlag pteeadjans)
(while
(not cFlag)
(initget "Duplicate Move Rotate")
(setq pteeadjans (getkword "\nAdjustment? [Duplicate/Move/Rotate]: "))
(cond
(
(= pteeadjans "Duplicate")
(command "_copy"
teep1
teep2
teep3
teep4
teep5
teep6
teep7
teep8
teep9
teep10 ""
pteept1
pause
) ; end copy
); end condition #1
(
(= pteeadjans "Move")
(command "_move"
teep1
teep2
teep3
teep4
teep5
teep6
teep7
teep8
teep9
teep10 ""
pause
pause
) ; end move
); end condition #2
(
(= pteeadjans "Rotate")
(command "_rotate"
teep1
teep2
teep3
teep4
teep5
teep6
teep7
teep8
teep9
teep10 ""
pause
pause
) ; end rotate
); end condition #3
(
T
(prompt "Exiting Adjustment Menu...")
(setq cFlag T)
); end condition #3
); end cond
); end while
(princ)
); end of program

; ========================================================================
; ************************** ****************************
; ************************** Tee Main Program ****************************
; ************************** ****************************
; ========================================================================

(defun teemain ()
(setq oldlayers3 (getvar "clayer"))
(setq oldsnaps3 (getvar "osmode"))
(initget 1 "Plan Elevation")
(setq teeans (getkword "\nSelect View: [Plan/Elevation]"))
(if
(= teeans "Plan")
(progn
(userteepvalues)
(pteevariablesetter)
(setvar "osmode" 0)
(teepdraw)
(setvar "osmode" oldsnaps3)
(setvar "clayer" oldlayers3)
(pteeadj)
) ; end progn
) ; end if
(if
(= teeans "Elevation")
(progn
(userteevalues)
(teevariablesetter)
(setvar "osmode" 0)
(teedraw)
(setvar "osmode" oldsnaps3)
(setvar "clayer" oldlayers3)
(teeadj)
) ; end progn
) ; end if
(princ)
)

; ========================================================================
; *************************** *************************
; *************************** END OF TEE PROGRAM *************************
; *************************** *************************
; ========================================================================

; ========================================================================
; ************************** Layer Creation ******************************
; ========================================================================

(defun CreateLayer (Name)
(if
(not (tblsearch "LAYER" Name))
(command "_.-layer" "_m" Name "_c" Name Name "")
); end if
); end of CreateLayer

; ========================================================================
; ************************************************************************
; ========================================================================

; ========================
; ***** *****
; ***** MAIN PROGRAM *****
; ***** *****
; ========================

; ===========================================================================================================
; ===========================================================================================================
; =====
(defun c:pf () ; =====
(prompt "\nInitialising...") ; =====
(setvar "cmdecho" 0) ; =====
; =====
; ---------------------------------- =====
; =====
(defun *error*(msg) ; =====
(if oldVars ; =====
(mapcar 'setvar varLst oldVars) ; =====
); end if =====
(princ "\nERROR Or ESC PRESSED... EXIT PIPE & FLANGE DRAUGHTSMAN by LEE McDONNELL. ") ; =====
(princ) ; =====
); end of *error* =====
; =====
; ---------------------------------- =====
; =====
(setq varLst(list "CMDECHO" "OSMODE" "CLAYER" "DIMSCALE") ; =====
oldVars(mapcar 'getvar varLst) ; =====
); end setq =====
(mapcar 'CreateLayer '("1" "2" "3" "4" "5")) ; =====
(initget 1 "Pipe Flange Elbow Tee") ; =====
(setq progdec (getkword "\nSelect Equipment [Pipe/Flange/Elbow/Tee]")) ; =====
(if ; =====
(= progdec "Pipe") ; =====
(pipemain) ; =====
) ; end if =====
(if ; =====
(= progdec "Flange") ; =====
(flangemain) ; =====
) ; end if =====
(if ; =====
(= progdec "Elbow") ; =====
(elbowmain) ; =====
) ; end if =====
(if ; =====
(= progdec "Tee") ; =====
(teemain) ; =====
) ; end if =====
(setvar "cmdecho" 1) ; =====
; (prompt "\nPIPE & FLANGE DRAUGHTSMAN by LEE McDONNELL COMPLETE.") ; =====
(princ) ; =====
) ; end MAIN PROGRAM =====
; =====
; ===========================================================================================================
; ===========================================================================================================

;(alert "PIPE & FLANGE DRAUGHTSMAN by Lee McDonnell ; <<----<< I was going to add this but it got annoying. :P
; \nSeptember 2008
; \nType \"PF\" to invoke"
;) ; end alert

; ========================================================================
; ************************************************************************
; *************************** ************************
; *************************** END OF MAIN PROGRAM ************************
; *************************** ************************
; ************************************************************************
; ========================================================================

(c:PF)

Advertisements