Lee Mac Posted October 29, 2008 Posted October 29, 2008 Hi All, I have created a LISP to insert various blocks into a drawing, depending on the user input. After the blocks are inserted, the line they are positioned on needs to be trimmed so that it does not overlap the block itself. All the blocks are 6 units wide, therefore I have programmed the LISP to create a circle, temporarily delete the block, and trim the line inside the circle. However, I keep getting an error returned when CAD reaches this stage of the program. Any help would be much appreciated. (defun c:valv (/ *error* oldVars varLst oldos oldlay vchx ln1 pt1 valvno ln1ent ang1 block1 c1) (defun *error*(msg) (if oldVars (mapcar 'setvar varLst oldVars) ); end if (princ "\nError or Esc pressed... Exit Program. ") (princ) ); end of *error* (setq varLst(list "CMDECHO" "OSMODE" "CLAYER" "DIMSCALE") oldVars(mapcar 'getvar varLst) ); end setq (setvar "cmdecho" 0) (setq oldos (getvar "osmode")) (setq oldlay (getvar "clayer")) (initget 1 "Ball Butterfly Diaphragm Gate Globe") (setq vchx (getkword "\nSpecify Valve Type [bAll/BUtterfly/Diaphragm/GAte/GLobe]: ")) (while (and (/= (setq ln1 (car (entsel "\nSelect Line for Valve: "))) nil) (/= (setq pt1 (getpoint "\nSelect Point for Valve: ")) nil) (/= (setq valvno (getstring "\nType Valve Number: ")) "") ) ; end and (setq ln1ent (entget ln1)) (setq ang1 (angle (cdr (assoc 10 ln1ent)) (cdr (assoc 11 ln1ent)) ) ; end angle ) ; end setq (setvar "clayer" "4") (setvar "osmode" 0) (cond ( (= vchx "Gate") (command "_.insert" "C:\\Users\\Lee Mac\\Documents\\Valves\\GATE VALVE.dwg" pt1 "" "" (rtd ang1) valvno ) ; end insert (setq block1 (entlast)) ) ; end condition 1 ( (= vchx "Globe") (command "_.insert" "C:\\Users\\Lee Mac\\Documents\\Valves\\GLOBE VALVE.dwg" pt1 "" "" (rtd ang1) valvno ) ; end insert (setq block1 (entlast)) ) ; end condition 2 ( (= vchx "Ball") (command "_.insert" "C:\\Users\\Lee Mac\\Documents\\Valves\\BALL VALVE.dwg" pt1 "" "" (rtd ang1) valvno ) ; end insert (setq block1 (entlast)) ) ; end condition 3 ( (= vchx "Butterfly") (command "_.insert" "C:\\Users\\Lee Mac\\Documents\\Valves\\BUTTERFLY VALVE.dwg" pt1 "" "" (rtd ang1) valvno ) ; end insert (setq block1 (entlast)) ) ; end condition 4 ( (= vchx "Diaphragm") (command "_.insert" "C:\\Users\\Lee Mac\\Documents\\Valves\\DIAPHRAGM VALVE.dwg" pt1 "" "" (rtd ang1) valvno ) ; end insert (setq block1 (entlast)) ) ; end condition 5 ) ; end cond ; ***TRIM*** (command "_circle" pt1 "3" ) ; end circle (setq c1 (entlast)) (command "_zoom" "W" (polar pt1 (/ (* 3 pi) 4) (/ 3 4) ) ; end polar (polar pt1 (/ (* 7 pi) 4) (/ 3 4) ) ; end polar ) ; end zoom (entdel block1) (command "_trim" c1 "" l1 "" ) ; end trim (command "_zoom" "P" ) ; end zoom (entdel block1) (setvar "clayer" oldlay) (setvar "osmode" oldos) ) ; end while (setvar "cmdecho" 1) ) ; end program (defun rtd (a) (* 180.0 (/ a pi)) ) ; end program Thanks in advance, Lee. Quote
TimSpangler Posted October 29, 2008 Posted October 29, 2008 You could try adding a wipeout behind each block.. No trimming required... Quote
ASMI Posted October 29, 2008 Posted October 29, 2008 Maybe ln1? (command "_trim" c1 "" [color="Red"]ln1[/color] "" ) ; end trim Quote
Lee Mac Posted October 29, 2008 Author Posted October 29, 2008 ASMI you are a legend You can always seem to spot my stupid mistakes Thanks! Quote
ASMI Posted October 30, 2008 Posted October 30, 2008 Good morning Lee Mac. If seriously you are very quickly trained but you should studies correctly to debug your programs. Look Help > Additional Resources > Developer Help > AutoLISP Tutorial > Using Visual LISP Debuging Tools. In addition this is Visual LISP Developer Bible by Devid M. Stain (vla-, vlax-, vlr-), please read section about Visual LISP Editor and debugging inside it. Quote
Lee Mac Posted October 30, 2008 Author Posted October 30, 2008 Thanks ASMI, I'll look into that Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.