;;;============================================= ;;; Makes a pipe run with wall thickness using ;;; Multiple polylines, 3dpolys, slines, arcs or ;;; lines. ;;; Will prompt for OD and Wall and to join ;;; Command=PIPERUN ;;; Autocad 2007 on up. ;;; Written by Jason Rhymes ;;; Find more 3d solid power toys at ;;; www.acadianagraphics.com ;;;============================================= (defun errtrap (errmsg) (if (not (member errmsg '("console break" "Function Cancelled")) ) (princ (strcat "\nError: " errmsg)) ;print message ) (command (command)) (command "._Undo" "Back") (setvar "osmode" curos) (setvar "cmdecho" curecho) (setq *error* temperr) ;restore *error* (prompt "\nResetting...") ;inform user (princ) ) (defun c:piperun (/ val1 val2 c1 sol1 pickpoint ss slent1 slent2 key solid1) (setq temperr *error*) ;store *error* (setq *error* errtrap) (setq curos (getvar "osmode") curecho (getvar "cmdecho") ) (command "._Undo" "Mark" "._Undo" "Group") (setvar "cmdecho" 0) (setvar "osmode" 0) (setq ss (ssget '((0 . "LINE,*POLYLINE,SPLINE,ARC")))) (if (null (numberp dfval1)) (setq dfval1 1.0) ) (setq val1 (getreal (strcat "\nEnter pipe OD: <" (rtos dfval1) ">: ") ) ) (if (= nil val1) (setq val1 dfval1) (setq dfval1 val1) ) (if (null (numberp dfval2)) (setq dfval2 0.25) ) (setq val2 (getreal (strcat "\nEnter pipe wall thickness: <" (rtos dfval2) ">: " ) ) ) (if (= nil val2) (setq val2 dfval2) (setq dfval2 val2) ) (setq solid1 (ssadd)) (setq i 0) (repeat (sslength ss) (command "._circle" '(0 0) val1) (command "._region" (entlast) "") (setq s1 (entlast)) (command "._circle" '(0 0) (- val1 val2)) (command "._region" (entlast) "") (setq s2 (entlast)) (command "._subtract" s1 "" s2 "") (setq slent2 (entlast)) (setq slent1 (ssname ss i)) (command "._sweep" slent2 "" "Base" '(0 0) slent1) (ssadd (entlast) solid1) (setq i (1+ i)) ) (if (not key_default) (setq key_default "Yes") ) (initget "Yes No") (setq key (getkword (strcat "\nJoin Piping?: [Yes/No]: <" key_default "> " ) ) ) (if (not key) (setq key key_default) (setq key_default key) ) (if (= key "Yes") (command "._union" solid1 "") ) (setvar "osmode" curos) (setvar "cmdecho" curecho) (command "._Undo" "End") (setq *error* temperr) (princ) ) (prompt "\nFind more 3d solid power toys at \nwww.acadianagraphics.com \n*** Type PipeRun to run the program ***" )