See the top rated post in this thread. Click here

Page 5 of 6 FirstFirst 123456 LastLast
Results 41 to 50 of 52

Thread: Lisp Legend

  1. #41
    All AUGI, all the time
    Join Date
    2010-06
    Posts
    962
    Login to Give a bone
    0

    Default Re: Lisp Legend

    Quote Originally Posted by _brxdvs View Post
    So, opened a new drawing and I am getting this error: ; error: bad argument type: VLA-OBJECT nil when using the code from yesterday.

    I think it has to do with some cogo points that don't have styles applied and are set to default, is there a way to exclude nil values?
    Hi,

    No, the program actually trying to retrieve data from vla-object which is nil.

    Can you post the codes that you are currently using?

  2. #42
    Member
    Join Date
    2017-10
    Location
    Florida
    Posts
    26
    Login to Give a bone
    0

    Default Re: Lisp Legend

    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)
    )

  3. #43
    All AUGI, all the time
    Join Date
    2010-06
    Posts
    962
    Login to Give a bone
    1

    Default Re: Lisp Legend

    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)

  4. #44
    Member
    Join Date
    2017-10
    Location
    Florida
    Posts
    26
    Login to Give a bone
    0

    Default Re: Lisp Legend

    Thank you once again.

    I tried using vl-remove but I guess it wont remove nil

  5. #45
    All AUGI, all the time
    Join Date
    2010-06
    Posts
    962
    Login to Give a bone
    0

    Default Re: Lisp Legend

    Quote Originally Posted by _brxdvs View Post
    Thank you once again.

    I tried using vl-remove but I guess it wont remove nil
    believe me, the problem as I have explained it in post# 41 and vl-remove function deletes specific element from a list and nothing's more.

  6. #46
    Member
    Join Date
    2017-10
    Location
    Florida
    Posts
    26
    Login to Give a bone
    0

    Default Re: Lisp Legend

    Thanks for your help.

  7. #47
    All AUGI, all the time
    Join Date
    2003-07
    Posts
    561
    Login to Give a bone
    0

    Default Re: Lisp Legend

    Something like this

    Code:
    (vlax-for j (vlax-get *AeccDoc* 'Pointstyles)
    (Setq ptstyname (vla-get-name j))
    )

  8. #48
    Member
    Join Date
    2017-10
    Location
    Florida
    Posts
    26
    Login to Give a bone
    0

    Default Re: Lisp Legend

    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.

  9. #49
    Member
    Join Date
    2017-10
    Location
    Florida
    Posts
    26
    Login to Give a bone
    0

    Default Re: Lisp Legend

    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

  10. #50
    Active Member
    Join Date
    2015-12
    Location
    Western Europe
    Posts
    57
    Login to Give a bone
    1

    Default Re: Lisp Legend

    Use the member or vl-position functions

    Code:
    (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
    The repeat is a bit clunky here to access members of a list


    Code:
    (foreach item list
      (do these..)
    );end_foreach

Page 5 of 6 FirstFirst 123456 LastLast

Similar Threads

  1. Replies: 5
    Last Post: 2016-01-10, 04:44 PM
  2. Replies: 7
    Last Post: 2014-05-15, 03:00 PM
  3. Tags in Legend Views / Tag legend components
    By Wish List System in forum Revit Architecture - Wish List
    Replies: 0
    Last Post: 2012-11-14, 07:08 AM
  4. Replies: 3
    Last Post: 2012-05-07, 08:16 PM
  5. Copy / Paste from Legend to Legend
    By antman in forum Revit Architecture - General
    Replies: 5
    Last Post: 2011-04-12, 03:22 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •