Lisp Error

Lisp Error

IkaroFalcao
Enthusiast Enthusiast
892 Views
2 Replies
Message 1 of 3

Lisp Error

IkaroFalcao
Enthusiast
Enthusiast

Hey Guys, whats up?

I am developing this code but there is some problem, could anyone help me? Please


(defun c:testea () (setq pon (getpoint)) (setq sel (ssget "x" '((0 . "INSERT") (8 . "ELE-BLK-PONTOS")))) (setq count 0 count2 0 hm (sslength sel) list2 '("AC" "AQ" "CF" "CH" "FE" "FP" "LL" "LM" "PM" "SN" "SPA" "TE" "TL" "TP") ) (while (< count hm) (if (equal (assoc 1 (entget (entnext (ssname sel count)))) '((progn (while (< count2 13) (if (equal (assoc 1 (entget (entnext (ssname sel count)))) '(strcat "1 ." (nth count2 list2)))(progn (command "_insert" (strcat "C:/PJ/Legenda/" (nth count list2) "(legenda)" pon "1" "" "0")) (setq count2 (1+ count2)))))))) )))

 

Thanks 

0 Likes
Accepted solutions (1)
893 Views
2 Replies
Replies (2)
Message 2 of 3

Jonathan3891
Advisor
Advisor
(if (equal (assoc 1 (entget (entnext (ssname sel count))))

Seems to me you need an else statement. 


Jonathan Norton
Blog | Linkedin
0 Likes
Message 3 of 3

Kent1Cooper
Consultant
Consultant
Accepted solution

Some things I notice [without digging deeply enough to understand fully what it's doing]:

 

'((progn ... and what follows is problematical.  The "result" of this is supposedly being compared to the (assoc 1 ... line above for (equal)ity -- otherwise the (equal) function doesn't compare anything.  I guess the return from a (progn) function can be compared like that, if it's done right.  But the asterisk prefix is invalid here.  See Help about the (list) and (quote) functions -- the asterisk requires that nothing inside needs evaluation -- no variables, no comparisons, etc. -- but what you have in it is loaded with variables and evaluating-type functions.

 

Nothing changes the value of the 'count' variable, so the (while) that is based on its value will never end, and will repeat operating on the same thing.

 

This line:

  (if (equal (assoc 1 (entget (entnext (ssname sel count)))) '(strcat "1 ." (nth count2 list2)))

is pretty wacky....  The 1-code entry in entity data is not a text string, and even if it were, there would need to be another space after the period.  I suspect what you need is something more like:
  (if (equal (assoc 1 (entget (entnext (ssname sel count)))) (cons 1 (nth count2 list2)))

 

The (strcat) function in the Insert command doesn't have a closing right parenthesis [it's trying to concatenate the insertion point into the string].

 

There are probably some other things -- those are just the ones that caught my eye.

Kent Cooper, AIA