Message 1 of 12

Not applicable
12-20-2017
12:39 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello, I am having a hard time getting this Lisp to run in autocad.It gives me a "too many arguments" error. It is supposed to create a legend based on the pointstyle name of the points. This is being modified to work with the pointstyle name of the cogo points, previously a tblnext was used on the blocks, and worked flawlessly.
any advice would be appreciated. Thanks.
(defun c:legend () (vl-load-com) (setq temperr *error*) ;store *error* (setq *error* trap1) ;re-assign *error* (setq oldhigh (getvar "Highlight") oldsnap (getvar "Osmode") oldecho (getvar "Cmdecho") oldtext (getvar "Textstyle") oldlay (getvar "clayer") ); gets variables to reset at the end of the routine ;;------------------------------------------------------------------------------------------------- (c:pointSelection); select cogo pointstyle names, defun at end of file ;;------------------------------------------------------------------------------------------------- (setvar "osmode" 0) ;turns off all snap in osnap (setvar "clayer" "LEGEND") (setvar "textstyle" "S80"); (setq lf 1) (setq curh (cdr (assoc 40 (tblsearch "STYLE" (getvar "textstyle"))))) (setvar "cmdecho" 1) ;;------------------------------------------------------------------------------------------------- (setq bbp (getpoint "\nPick start of legend: ")) (setq lfile (open "P:\\Lisp\\LEGEND.TXT" "r")) (setq bllist nil) (while (setq blockn (read-line lfile)) (setq blockd (read-line lfile)) (setq bllist (cons (list blockn blockd) bllist)) ) (close lfile) (setq lfile (open "P:\\Lisp\\LEGEND.TXT" "a")) (setq n (sslengtth styleList) cnt 1 index 0) (repeat n (setq bname (nth index styleList)) (setq bdesc (cadr (assoc bname bllist))) (command-s "insert" bname (setq cbp (polar bbp (/ (* 270 PI) 180) (* cnt (/ lf 3)))) lf "" 0.0 ) (if (= curh 0.0) (command-s "TEXT" "j" "ml" (polar cbp 0 (/ lf 1.6)) (* lf 0.08) 0.0 (STRCAT "= " BDESC) ) (command-s "TEXT" "j" "ml" (polar cbp 0 (/ lf 1.6)) 0.0 (STRCAT "= " BDESC) ) ) (setq cnt (1+ cnt) index (1+ index)) );end repeat ;;------------------------------------------------------------------------------------------------- ;;end of routine (close lfile) (setvar "Highlight" oldhigh) (setvar "Osmode" oldsnap) (setvar "Cmdecho" oldecho) (setvar "textstyle" oldtext) (setvar "clayer" oldlay); returns vars to orignal state before lisp (princ) ) ;end defun Legend (setq *error* temperr) ;restore *error* (defun trap1 (errmsg) ;define function ;(command-s "u" "b") ;undo back (setvar "osmode" oldsnap) ;restore variables (setvar "highlight" oldhigh) (setvar "cmdecho" oldecho) (setvar "textstyle" oldtext) (setvar "clayer" oldlay) (setq *error* temperr) ;restore *error* (prompt "\nRe-Setting System Variables " temperr) ;inform user ) (defun c:pointselection (/ pntSel index pntStyle pntName styleList) (vl-load-com) (if (setq pntSel (ssget "X" '((0 . "AECC_COGO_POINT")))) (progn (repeat (setq index (sslength pntSel)) (and (setq pntStyle (vlax-get (vlax-ename->vla-object (ssname pntSel (setq index (1- index)))) 'style)) (setq pntName (vlax-get-property pntStyle 'name)) (or (member pntName styleList) (setq styleList (cons pntName styleList)) ) ) ) ) )(princ) )
Solved! Go to Solution.