|
Code:(defun c:pointtest (/ selpnt n index pntlist point pntstyle stylelist pntname) (vl-load-com) (if (setq selpnt (ssget "X" '((0 . "AECC_COGO_POINT")))) ;selects the cogo points (progn (setq n (sslength selpnt)) (setq index 0) (repeat n (setq pntlist (entget (ssname selpnt index))) (setq point (vlax-ename->vla-object (cdr (assoc -1 pntlist)))) (setq pntstyle (vlax-get point 'style)) (setq pntname (vlax-get-property pntstyle 'name)) (if (not (member pntname stylelist)) (setq stylelist (cons pntname stylelist)) ) (setq index (1+ index)) ) ) ) (print stylelist);used for testing (princ) )
Here is the codes with the same goal and its more than enough and even if you run the program on new drawing or on a drawing that does not have that cogo points then it should be not throw any error message on the command line.
Code:(defun c:pointtest (/ ss i s n l) (if (setq ss (ssget "X" '((0 . "AECC_COGO_POINT")))) (progn (repeat (setq i (sslength ss)) (and (setq s (vlax-get (vlax-ename->vla-object (ssname ss (setq i (1- i)))) 'style)) (setq n (vlax-get-property s 'name)) (or (member n l) (setq l (cons n l)) ) ) ) (print l) ) ) (princ) ) (vl-load-com)
Thank you once again.
I tried using vl-remove but I guess it wont remove nil
Something like this
Code:(vlax-for j (vlax-get *AeccDoc* 'Pointstyles) (Setq ptstyname (vla-get-name j)) )
Ok so i have created the LISP to run the legend routine. It works as expected and has one fatal flaw. the routine compares the point style to a list, then uses this list to insert a legend in text form. The problem comes when there are point styles we don't want in the legend. I understand if statements but i can't seem to get the context right. I want to exclude items that are not in the list. Any help would be appreciated.
Here is some of the code I need assistance with adding the IF statements to exclude point styles that don't appear in a list.
Code:(setq lfile (open "z:\\_CAD\\LISP\\LEGENDBLOCKS.TXT" "r")) (setq n (length styleList) cnt 1 index 0) ;NEED CONDITIONAL STATEMENTS TO LEAVE OUT UNKNOWN BLOCKS (repeat n (setq bname (nth index styleList)) (setq bdesc (cadr (assoc bname bllist))) ;(if (not ) ; (setq cnt (1+ cnt) ; index (1+ index)));end if (progn (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) ) );end if (setq cnt (1+ cnt) index (1+ index)) ); end progn );end repeat
Use the member or vl-position functions
The repeat is a bit clunky here to access members of a listCode:(if (member item list) (progn (do these..) .... ) ) or (cond ( (member item list) (do these..) ..... ) );end_cond ;vl-position will require (vl-load-com) (if (vl-position item list) (progn (do these..) ..... ) ) or (cond ( (vl-position item list) (do these..) ...... ) );end_cond
Code:(foreach item list (do these..) );end_foreach