RecipesAutoLISP
My AutoLISP routine throws an error. Can AI fix it and run it in AutoCAD?
Yes. Paste the routine with "this fails with bad argument type: lselsetp: nil, fix it and run it". cadssistant runs it in your AutoCAD, sees the actual error and the state that caused it (an ssget that returned nil, a variable that was never set, a function that doesn't exist in your release), corrects the routine and runs it again, then replies with what was wrong and the working code. Unlike pasting into a browser chatbot, the fix is tested against your drawing before you get it.
Checked 2026-10-30
this LISP fails with 'bad argument type: lselsetp: nil' - fix it and run it: (paste the routine here)
What cadssistant does
- Runs the routine in your drawing, so the error is the real one from your release and your drawing, not a guess. A very long routine is best trimmed to the part that fails.
- Reads the message back: lselsetp: nil here means sslength got nil instead of a selection set, so the ssget found nothing (wrong layer name, nothing matched, or a quoting slip in the filter). It can check which with a read before changing the code.
- Rewrites the routine with the guard, runs it again, and replies with the diagnosis and the corrected code, ready to save as a .lsp.
The same task in AutoLISP
;; Before: errors when nothing matches, because ssget returned nil
(repeat (sslength ss) ...)
;; After: guard the selection
(if (setq ss (ssget "_X" '((0 . "CIRCLE"))))
(repeat (sslength ss) ...)
(prompt "\nNo circles found."))The most common AutoLISP error, and the first thing it checks: ssget returns nil, not an empty set, when nothing matches.
Good to know
- Visual LISP functions (vla-, vlax-) sometimes need (vl-load-com) first; a "no function definition" error on one of them is the sign.
More in autolisp
Command: CADSSISTANT
Works in AutoCAD 2024 and newer on Windows. Free trial, no card, no API key.
Get cadssistant