Go Back   Cadalyst Discussion Forums > Forums > Hot Tip Harry: AutoCAD Customization
FAQ Members List Social Groups Calendar Search Today's Posts Mark Forums Read

Notices

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  
Old 01-12-2012, 07:41 PM
mattsibum mattsibum is offline
Member
 
Join Date: Nov 2007
Posts: 34
Default Help with bad argument type: lentityp nil

Hi, got this part of a lisp that is returning an error when nothing is selected

Code:
"bad argument type: lentityp nil"
Not sure why the 'if' statement isn't working, displaying the "Nothing Selected... Program Closing" message when 'objsel' variable returns 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
Any help would be great.
Matt
  #2  
Old 01-12-2012, 10:25 PM
Walt Bedinger Walt Bedinger is offline
Senior Member
 
Join Date: Oct 2007
Location: Greeley, Colorado
Posts: 274
Default

(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  
Old 01-13-2012, 01:27 AM
mattsibum mattsibum is offline
Member
 
Join Date: Nov 2007
Posts: 34
Default

Beautiful :-)

Thanks a lot.. Seems i am trying to achieve too much with one line of code.
  #4  
Old 01-13-2012, 01:53 PM
Cap'n Mac's Avatar
Cap'n Mac Cap'n Mac is offline
Senior Member
 
Join Date: May 2002
Location: Bryan, Texas
Posts: 2,195
Default Not so much too much as too little

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

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -6. The time now is 09:08 AM.





Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.