;;; pipe.lsp ;;; ;;; copyright (c) 1998 by charles w. robbins ;;; ;;; Charles Robbins provides this code for your use. Use the code ;;; to your benifit and at your own risk. Charles Robbins does not ;;; warrant that the code is error free in your application. (alert "pipe.lsp - copyright (C) 1998, Charles W. Robbins. Type pipe to start") (defun c:pipe (/) ;;; drawing setup (setq osm (getvar "osmode")) (setvar "osmode" 0) (command "layer" "n" "dimension" "c" "red" "dimension" "") (command "layer" "n" "center" "c" "green" "center" "lt" "center" "center" "") (command "layer" "n" "hidden" "c" "magenta" "hidden" "lt" "hidden" "hidden" "") (command "layer" "s" "0" "") ;;; get information (setq sp (getpoint "\npick the center of the pipe "))(terpri) (setq w (getreal "\nwhat is the length of the pipe "))(terpri) (setq q1 "n") (while (= q1 "n") (setq id (getreal "\nwhat is the inside dim of the pipe "))(terpri) (setq od (getreal "\nwhat is the outside dim of the pipe "))(terpri) (if (> od id)(setq q1 "y")) (if (>= id od)(print "outside diameter must be larger than the inside diameter")) ) ;;; math (setq x0 (car sp) x1 (- x0 (/ od 2.0) 0.125) x2 x0 x3 (+ x0 (/ od 2.0) 0.125) x4 (+ x0 (* 1.5 od)) x5 (+ x4 0.125) x6 (+ x5 w) x7 (+ x6 0.125) ) (setq y0 (cadr sp) y1 (- y0 (/ od 2.0) 0.125) y2 (+ y1 0.125) y3 (- y0 (/ id 2.0)) y4 y0 y5 (+ y0 (/ id 2.0)) y6 (+ y0 (/ od 2.0)) y7 (+ y6 0.125) y8 (+ y6 0.5) ) (setq p1 (list x5 y2) p2 (list x6 y2) p3 (list x5 y3) p4 (list x6 y3) p5 (list x4 y4) p6 (list x7 y4) p7 (list x5 y5) p8 (list x6 y5) p9 (list x5 y6) p10 (list x6 y6) p11 (list x3 y4) p12 (list x2 y7) p13 (list x1 y4) p14 (list x2 y1) p15 (list x2 y4) p16 (list x5 y8) ) (command "circle" p15 "d" od) (command "circle" p15 "d" id) (command "line" p1 p2 p4 p8 p10 p9 p7 p3 "c") (command "layer" "s" "hidden" "") (command "line" p4 p3 "") (command "layer" "s" "center" "") (command "line" p6 p5 "") (command "layer" "s" "hidden" "") (command "line" p8 p7 "") (command "layer" "s" "center" "") (command "line" p12 p14 "") (command "line" p13 p11 "") (command "zoom" "e") (command "layer" "s" "dimension" "") (setvar "dimscale" 0.667) (setvar "dimdec" 2) (command "dimlinear" p9 p10 p16) (setq odpt (list (+ x0 (/ od 4.0)) (+ y0 (* (/ od 4.0)(sqrt 3))) )) (command "dimdiameter" odpt "@0.5,0.5") (setq idpt (list (+ x0 (* (/ id 4.0)(sqrt 3))) (+ y0 (/ id 4.0)) )) (command "dimdiameter" idpt "@0.5,0.5") ;;; end of drawing (command "zoom" "e") (setvar "osmode" osm) (gc) (princ) )