|
|||||||
| Hot Tip Harry: AutoCAD Customization Cadalyst's popular Hot Tip Harry and his entourage are here to assist you with AutoCAD customization. Request help with a programming problem, locate a needed routine, or just keep up with Harry's latest activities. You'll find Harry's archive of AutoLISP and VBA code and hatch patterns at www.cadalyst.com/cadtips. Moderated by R.K. McSwain. |
|
|
Thread Tools | Display Modes |
|
#1
|
|||
|
|||
|
Hi, got this part of a lisp that is returning an error when nothing is selected
Code:
"bad argument type: lentityp nil" Code:
(if (setq objsel (entget (car (nentsel "\nSelect Objects to Change Layer Colour...")))) (progn (setq layget (cdr (assoc 8 objsel))) (progn (if (and (/= layget "0")(/= layget "Defpoints")) (command "-layer" "c" laycol layget "" "") (princ "\nCannot Modify Layer 0 or Defpoints...") );END IF );END PROGN );END PROGN (princ "\nNothing Selected... Program Closing...") );END IF Matt |
|
#2
|
|||
|
|||
|
(if (setq obj (nentsel "\nSelect Objects to Change Layer Colour..."))
(progn (setq objsel (entget (car obj)) layget (cdr (assoc 8 objsel)) ) (progn (if (and (/= layget "0")(/= layget "Defpoints")) (command "-layer" "c" laycol layget "" "") (prompt "\nCannot Modify Layer 0 or Defpoints...") );END IF );END PROGN );END PROGN (prompt "\nNothing Selected... Program Closing...") );END IF |
|
#3
|
|||
|
|||
|
Beautiful :-)
Thanks a lot.. Seems i am trying to achieve too much with one line of code. |
|
#4
|
||||
|
||||
|
The trick is to remember to always check for a nil condition from any user response.
That, or to "force" one using (initget). The other thing to watch for is the last value of a (while) or (tblnext) or similar loop. One of the great freedoms LISP gives is that you need not define a variable, it can be integer, real, string, atom, list, whatever, and it can change each time it is (set(equal))--aka (setq)--to something. Which is why the (typ) subr is needful, and, occasionally, handy. |
| Thread Tools | |
| Display Modes | |
|
|