;;; autobom.lsp a lisp routine that generates a bom ;;; ;;; Copyright (C) 1998 by Denzil Hill and Charles Robbins ;;; ;;; Denzil Hill and Charles Robbins provide this code for your use. ;;; Use the code to your benifit and at your own risk. Denzil Hill and ;;; Charles Robbins do not warrant that the code is error free in your application. (alert "autobom.lsp - copyright 1998 by Denzil Hill and Charles Robbins. Type autobom to start") (defun c:autobom (/) ;;; drawing setup (setq osm (getvar "osmode")) (setvar "osmode" 0) ;;; Pick insertion point (setq sp (getpoint "\nPick your insertion point ....")) (setq w (getreal "\nWhat is the height of the text...? ")) (initget 1 "y n") (setq q2 (getkword "\nDo you want the program to count for you [y or n]...? ")) (setq h (* 2.0 w)) (setq text1 "1") ;;; Math (setq x1 (car sp)) (setq x2 (+ x1 (* h 2.6 ))) (setq x3 (+ x1 (* h 11.0))) (setq x4 (+ x1 (* h 23.0))) (setq x5 (+ x1 (* h 27.0))) (setq x6 (+ x1 (* h 29.0))) (setq x7 (+ x1 (* h 14.5))) (setq x8 (+ x1 (/ (- x2 x1) 2.0))) (setq x9 (+ x2 (/ (- x3 x2) 2.0))) (setq x10 (+ x3 (/ (- x4 x3) 2.0))) (setq x11 (+ x4 (/ (- x5 x4) 2.0))) (setq x12 (+ x5 (/ (- x6 x5) 2.0))) (setq y1 (cadr sp)) (setq y2 (+ y1 h)) (setq y3 (+ y1 (* h 2.0))) (setq y4 (+ y1 (* h 3.0))) (setq y5 (+ y3 (* h 0.25))) (setq y6 (+ y2 (* h 0.25))) (setq y7 (+ y1 (* h 0.25))) ;;; Point assignment (setq pt1 sp) (setq pt2 (list x2 y1)) (setq pt3 (list x3 y1)) (setq pt4 (list x4 y1)) (setq pt5 (list x5 y1)) (setq pt6 (list x6 y1)) (setq pt7 (list x6 y2)) (setq pt8 (list x6 y3)) (setq pt9 (list x6 y4)) (setq pt10 (list x4 y3)) (setq pt11 (list x3 y3)) (setq pt12 (list x2 y3)) (setq pt13 (list x1 y4)) (setq pt14 (list x1 y3)) (setq pt15 (list x1 y2)) (setq pt16 (list x5 y3)) (setq pt17 (list x7 y5)) (setq pt18 (list x8 y6)) (setq pt19 (list x9 y6)) (setq pt20 (list x10 y6)) (setq pt21 (list x11 y6)) (setq pt22 (list x12 y6)) (setq pt23 (list x8 y7)) (setq pt24 (list (+ x2 w) y7)) (setq pt25 (list (+ x3 w) y7)) (setq pt26 (list (+ x4 w) y7)) (setq pt27 (list x12 y7)) ;;; Draws the lines (command "line" pt13 pt9 "") (command "line" pt15 pt7 "") (command "line" pt14 pt8 "") (command "line" pt1 pt13 "") (setq ss1 (ssget "L")) (command "line" pt2 pt12 "") (setq ss2 (ssget "L")) (command "line" pt3 pt11 "") (setq ss3 (ssget "L")) (command "line" pt4 pt10 "") (setq ss4 (ssget "L")) (command "line" pt5 pt16 "") (setq ss5 (ssget "L")) (command "line" pt6 pt9 "") (setq ss6 (ssget "L")) ;;; Does text (command "text" "j" "c" pt18 w "" "ITEMS" "") (command "text" "j" "c" pt19 "" "" "PART NUMBER" "") (command "text" "j" "c" pt20 "" "" "DESCRIPTION" "") (command "text" "j" "c" pt21 "" "" "REMARKS" "") (command "text" "j" "c" pt22 "" "" "QTY." "") (command "text" "j" "c" pt17 "" "" "BILL OF MATERIAL" "") (initget 1 "y n") (setq q1 (getkword "\nDo you want to add an item to the Bill of Material [y or n]...? ")) (while (= q1 "y") (progn (if (= q2 "n") (progn (setq text1 (getstring T "\n item number ")) (command "text" "j" "c" pt23 "" "" text1 "") ) ) (if (= q2 "y") (progn (command "text" "j" "c" pt23 "" "" text1 "") (setq text1 (atoi text1)) (setq text1 (1+ text1)) (setq text1 (itoa text1)) ) ) (setq text2 (getstring T "\n part number ")) (command "text" pt24 "" "" text2 "") (setq text3 (getstring T "\n description ")) (command "text" pt25 "" "" text3 "") (setq text4 (getstring T "\n remarks ")) (command "text" pt26 "" "" text4 "") (setq text5 (getstring T "\n qty ")) (command "text" "j" "c" pt27 "" "" text5 "") (command "line" pt1 pt6 "") (initget 1 "y n") (setq q1 (getkword "\nDo you want to add an item to the Bill of Material [y or n]...? ")) (setq y7 (- y7 h)) (setq pt23 (list x8 y7)) (setq pt24 (list (+ x2 w) y7)) (setq pt25 (list (+ x3 w) y7)) (setq pt26 (list (+ x4 w) y7)) (setq pt27 (list x12 y7)) (setq y1 (- y1 h)) (setq pt1 (list x1 y1)) (setq pt6 (list x6 y1)) (command "zoom" "extents" "") ) ) ;;; loop computations (setq ss7 (ssget "L")) (command "extend" "L" "" ss1 ss2 ss3 ss4 ss5 ss6 "") ;;; drawing end (setvar "osmode" osm) (gc) (princ) )