AutoLISP
You too can get Lost In Stupid Parentheses
This is a collection of autolisp routines I wrote to automate many repetitive drafting jobs. For now they are all on this one page. I have others on floppy somewhere, or I may have a copy on my Amiga machine... hafta check and some day when I feel like thumbing through a few hundred floppies i might find them.
These may not be useful to anyone other than those at this particular previous employer of mine. But if you find it useful in some way, let me know and most likely I'll give permission to use them however you like. If you do happen to find it serving your needs and feel guilty, donations are certainly welcome. ;-) I put quite a few hours of my own time into the development of this 'drafting automation system' project, which saved several hundred manhours and allowed me to accomplish the work equivalent of three typical draftsmen. I, of course, received no recognition or reward for it (besides more work and the expectation that any drafting project could be done just as quickly). But it made the monotonous tasks faster and exemplified an obvious (IMHO) place to maximize efficiency using the AutoCad system. I also happened to enjoy the designing, programming and debugging of these routines more than the simple repetitive drafting.
This routine will automatically create a detail drawing for nozzles and manways as used in steel tank construction/repair work. It is dependent on other dwg files (mainly the border template with properly related detail weld specs) and particularly formatted text files (mainly specifying the API or other applicable standards for the drawing).
;* Automated Nozzle drawing lisp routine.
;* Developed By: Thomas W. Johnson III - CADD Systems Specialist
;*
;* Copyright (c)1995 Thomas W. Johnson III - All Rights Reserved.
;* this program is subject to all applicable copyright laws and may not
;* be altered for any reason without express consent of developer.
;; development start date: 9/94
;; change to multiple nozzles - updated: 6/95
;; ** Nozzle Information
(prompt "Loading Nozzle Program. Please Wait.............")
(alert
(strcat "NOTICE: The following must be done prior"
" to running the Nozzle Program."
"\nCreate Job.txt file in proper directory using the Form.lsp program."
"\nHave a New or Blank dwg file currently in the drawing editor.")
);alert
;;*****Nozzle Flange information subroutine***
(defun NozF ()
;;** select nozzle size
(Prompt
(strcat "\nPenetration Number (from left to right) - " (itoa count))
);prompt
(while
(not
(and
(if
(= count 1)
(Setq Ns
(Getstring "\nEnter the Size of the Leftmost Penetration: ")
);setq Then
(setq Ns
(getstring "\nEnter the Size of the Next Penetration to the Right: ")
);setq Else
);if
;;** AND
(cond ((= Ns "2") (Prompt "2 Inch Nozzle Selected.") Ns)
((= Ns "3") (Prompt "3 Inch Nozzle Selected.") Ns)
((= Ns "4") (Prompt "4 Inch Nozzle Selected.") Ns)
((= Ns "6") (Prompt "6 Inch Nozzle Selected.") Ns)
((= Ns "8") (Prompt "8 Inch Nozzle Selected.") Ns)
((= Ns "10") (Prompt "10 Inch Nozzle Selected.") Ns)
((= Ns "12") (Prompt "12 Inch Nozzle Selected.") Ns)
((= Ns "14") (Prompt "14 Inch Nozzle Selected.") Ns)
((= Ns "16") (Prompt "16 Inch Nozzle Selected.") Ns)
((= Ns "18") (Prompt "18 Inch Nozzle Selected.") Ns)
((= Ns "20") (Prompt "20 Inch Penetration Selected.") Ns)
((= Ns "22") (Prompt "22 Inch Nozzle Selected.") Ns)
((= Ns "24") (Prompt "24 Inch Penetration Selected.") Ns)
((= Ns "30") (Prompt "30 Inch Penetration Selected.") Ns)
((= Ns "36") (Prompt "36 Inch Penetration Selected.") Ns)
(Ns (prompt (strcat "Error: Unknown Nozzle Size. [ " Ns " ]."
"\nRe-enter Nozzle Size or Update Program Code.")))
);cond
);and
);not
);while
(setq Ns (atof Ns));setq ** converts ns string to a real **
;;** if penetration is greater than 20" and a Manway then goto mw subr
;;** otherwise continue with nozzle subr
(if (>= ns 20)
(setq pen
(strcase
(getstring "\nIs this penetration a (M)anway or a <N>ozzle: ")
);strcase
);setq
);if
(if (= pen "M") (mw))
;;** default nozzle centerlines Hn=Regular Height, Hl=Low Type
(cond ((< Ns 2.0)(setq Hn 6.0))
((= Ns 2.0)(setq Hn 7.0))
((= Ns 3.0) (setq Hn 8.0))
((= Ns 12.0)(setq Hn 17.0))
((>= Ns 14.0) (setq Hn (- 52.0(- 48.0 Ns))) )
((and (> Ns 3.5) (< ns 12)) (setq Hn (- 53.0(- 48.0 Ns))) )
);cond
(cond ((< Ns 2.0)(setq Hl 3.0))
((= Ns 2.0)(setq Hl 3.5))
((= Ns 3) (setq Hl 5.25))
((= Ns 4) (setq Hl 6.0))
((= Ns 6) (setq Hl 7.875))
((>= Ns 26.0) (setq Hl (- 48.375(- 48.0 Ns))))
((>= Ns 14.0) (setq Hl (- 24.75(- 24.0 Ns))))
((>= Ns 8.0) (setq Hl (- 13.5(- 12.0 Ns))))
);cond
;;*default 'j' dimensions
(cond ((<= Ns 2.0)(setq J 6.0))
((<= Ns 4.0)(setq J 7.0))
((<= Ns 8.0)(setq J 8.0))
((<= Ns 12.0)(setq J 9.0))
((<= Ns 18.0)(setq J 10.0))
((<= Ns 22.0)(setq J 11.0))
((<= Ns 30.0)(setq J 12.00))
((<= Ns 34.0)(setq J 13.00))
((<= Ns 38.0)(setq J 14.00))
);cond
;;**nozzle outside diameters
(cond ((or (= Ns 2.0) (= Ns 2.5)) (setq NozOd (+ Ns 0.375)))
((or (= Ns 3.0) (= Ns 4.0)) (setq NozOd (+ Ns 0.5)))
((or (= Ns 6.0) (= Ns 8.0)) (setq NozOd (+ Ns 0.625)))
((or (= Ns 10.0) (= Ns 12.0)) (setq NozOd (+ Ns 0.75)))
((>= Ns 14) (setq NozOd Ns))
);cond
;;** set neck wall thickness
(cond ((= Ns 2.0)(setq NWall ".218"))
((= Ns 2.5)(setq NWall ".276"))
((= Ns 3.0)(setq NWall ".300"))
((= Ns 3.5)(setq NWall ".318"))
((= Ns 4.0)(setq NWall ".337"))
((= Ns 5.0)(setq NWall ".375"))
((= Ns 6.0)(setq NWall ".432"))
((>= Ns 8.0)(setq NWall ".500") )
);cond
;;**set inside and outside 'J' dimensions
(princ "\nDefault API 'J' Dimension for this nozzle is: ")(princ (rtos j))
(setq j (rtos j))
(setq Ji
(getstring
(strcat "\nEnter the inside 'J' dimension for this nozzle <" j "> : ")
);getstring
);setq
(if
(or (= ji "") (= ji " ")
);or
(setq ji j)
(setq ji (atof ji))
);if
(setq Jo
(getstring
(strcat "\nEnter the outside 'J' dimension for this nozzle <" j "> : ")
);getstring
);setq
(if
(or (= jo "") (= jo " ")
);or
(setq jo j)
(setq jo (atof jo))
);if
;;** show user default API center lines for selected nozzle size
(princ "\nRegular Type Centerline for this nozzle is: ")(princ (rtos Hn))
(princ "\n ")
(princ "Low Type Centerline for this nozzle is: ")(princ (rtos Hl))
(princ "\n ")
(setq Cl
(Getstring "\nEnter the Centerline Height or <Regular>, (L)ow type: ")
);setq
(setq Cl (strcase Cl))
(cond ((or (= Cl "R") (= Cl "")) (setq Cl Hn))
((= cl "L") (setq cl hl))
((setq cl (atof cl)))
);cond
(if (= NozNoz 1)
;THEN
(setq Lft
(Getstring (strcase (strcat "\nDistance from left edge of insert"
" plate to CL of nozzle or <S>ymmetrical: "))
);getstring
);setq
;ELSE
(while
(not
(setq Lft
(Getreal "\nDistance from left edge of ins plate to CL of nozzle: ")
);setq
);not
);while
);if
;;** Create list of nozzle variables for each nozzle in insert plate **
(cond
((= count 1) (setq Pen1 (list Ns cl lft ji jo nwall nozod)))
((= count 2) (setq Pen2 (list Ns cl lft ji jo nwall nozod)))
((= count 3) (setq Pen3 (list Ns cl lft ji jo nwall nozod)))
((= count 4) (setq Pen4 (list Ns cl lft ji jo nwall nozod)))
((= count 5) (setq Pen5 (list Ns cl lft ji jo nwall nozod)))
((= count 6) (setq Pen6 (list Ns cl lft ji jo nwall nozod)))
);cond
(setq Ns (itoa (fix Ns)))
(Setq Ns (strcat "N:\\msi\\proj\\stddets\\nozzles\\Nz" Ns))
(if (= count 1) (setq Alft lft))
(if (= count NozNo) (ins))
(setq count (1+ count))
(nozf)
);defun NozF end
;;** define INSert PLate subroutine **
(defun ins ()
(setq Wd (Getreal "Enter the Width of Insert Plate: ")
Hgt (Getreal "Enter the Height of Insert Plate: ")
Th (Getreal "Enter Insert Plate Thickness: ")
Bt (Getreal "Enter Bottom Thickness at Shell: ")
)
);defun ins end
(defun one ()
;;**if single nozzle in insert plate and symettrical adjust 'Lft' point**
(setq Wd (Getreal "Enter the Width of Insert Plate: ")
Hgt (Getreal "Enter the Height of Insert Plate: ")
Th (Getreal "Enter Insert Plate Thickness: ")
Bt (Getreal "Enter Bottom Thickness at Shell: ")
)
(If
(Or (= Lft "") (= Lft "S")
);or
(Setq Lft (* Wd 0.5));;setq THEN
(Setq Lft (atof Lft));;setq ELSE
);if
);defun one
(defun mw ()
(setq pen nil)
(prompt "\n Mw subroutine done")
(prot)
);defun mw
;(setq Sh (Getreal "Enter Shell Thickness: "))
;(setq Bvl (* 4 (- Th Sh)))
;* Draw Front View of Nozzle Insert
;(COMMAND "xref" "a" Ns "0,0" "1" "1" "0")
;(Setq Ctr (getvar "lastpoint")
; X1 (- (- Lft (car Ctr)))
; Y1 (- (- Cl (cadr Ctr)))
;);setq
;(EntMake '((0 . "polyline")))
;(EntMake (list (quote (0 . "vertex")) (list 10 X1 Y1)))
;(EntMake (list (quote (0 . "vertex")) (list 10 X1 (+ Hgt Y1))))
;(EntMake (list (quote (0 . "vertex")) (list 10 (+ Wd X1) (+ Hgt Y1))))
;(EntMake (list (quote (0 . "vertex")) (list 10 (+ Wd X1) Y1)))
;(EntMake '((0 . "seqend")))
;(Setq Sp (list x1 y1)
; Bp1 (list (- X1 5) Y1)
; Bp2 (list (+ x1 wd 5) Y1)
; of1 (List X1 (- Y1 5))
; BrkPt1 (list (- (car bp1) 5) (- Y1 (/ bt 2)))
; BrkPt2 (list (+ (car bp2) 5) (- Y1 (/ bt 2)))
; Fr (if (<= Sh 1) 6 (* Sh 6))
; Ep1 (list (- x1 4) (+ y1 0.25))
; Ep2 (list (+ x1 wd 4) (+ y1 0.25))
;
;);setq
;
;(Command "Fillet" "r" Fr "Fillet" "p" "l")
;(Command "offset" bvl Sp Ctr "")
;(Command "line" bp1 bp2 "")
;(Command "offset" bt bp1 of1 "")
;(Command "insert" "m:\\msi\\proj\\stddets\\misc\\brk" Brkpt1 1 1 0)
;(command "explode" "l")
;(command "move" "l" "" "0,0" "-1,0")
;(command "extend" "l" "" "f" Ep1 "@2<270" "" "")
;(Command "insert" "m:\\msi\\proj\\stddets\\misc\\brk" Brkpt2 1 1 0)
;(command "explode" "l")
;(command "move" "l" "" "0,0" "1,0")
;(command "extend" "l" "" "f" Ep2 "@2<270" "" "")
;** Noz Main Program
(Defun C:NOZ ( )
;;** set Absolute or Constant and global variables
(setq abs1 (list 0.0 0.0))
(setq count 1)
;;** program termination alert sub (currently not called by program)
(defun prot ()
(alert "FATAL ERROR: Program Termination")
(PRINC)
^c^C
);defun end
(Setvar "Cmdecho" 1)
(setq NozNo (Getint "How Many Nozzles in Insert Plate: "));setq
(while (or (= NozNo "") (> Nozno 6))
(alert (strcat "FATAL ERROR: Maximum of 6 nozzles in one"
"\ninsert plate permitted by program."))
(setq NozNo (Getint "How Many Nozzles in Insert Plate: "));setq
);while
;;**** Run Nozf subroutine ****
(NozF)
;;**** Run ins subroutine ****
(if (= NozNo 1) (one) (ins))
);*Defun
Routine to draw an insert plate of steel
(DEFUN C:INSPLT (/ osm agd anu cmd p1 w l p0 o r x1 )
(setq osm (getvar "osmode"))
(setq agd (getvar "angdir"))
(setq anu (getvar "aunits"))
(setq cmd (getvar "cmdecho"))
(setvar "osmode" 1056)
(setvar "aunits" 3)
(setvar "cmdecho" 0)
(setq p1 (getpoint "\nSnap to vert: "))
(setq w (getdist "\nWidth of insert plate: "))
(setq l (getdist "\nDistance from vert to C.L. of plate (-CW +CCW) : "))
(setvar "osmode" 0)
(setq p0 (list 0 0))
(setq o (- (abs l) (/ w 2.0)))
(command "point" (setq p p1))
(setq r (distance p0 p1))
(if (< l 0.0 ) (setvar "angdir" 1) (setvar "angdir" 0))
(command "rotate" "l" "" "0,0" (/ o r))
(setq x1 (cdr (assoc 10 (entget (entlast)))))
(command "erase" "l" "")
(command "arc" x1 "c" "0,0" "a" (/ w r))
(command "pedit" "l" "y" "w" "3.0" "x" )
(setvar "osmode" osm)
(setvar "aunits" anu)
(setvar "angdir" agd)
(setvar "cmdecho" cmd)
(princ)
)

