From the course: Learning AutoLISP & Visual LISP
Unlock the full course today
Join today to access over 22,700 courses taught by industry experts or purchase this course individually.
Error trapping - AutoCAD Tutorial
From the course: Learning AutoLISP & Visual LISP
Error trapping
- [Narrator] Throughout all of our lists, routines, or functions we have trapped when a user may not provide us what we're looking for. But what would happen if the user pressed the escape key during our Lisp function? What would happen if our code errors during an operation? So lets talk a little bit about how to exit an error or even a user hitting escape gracefully. To control what happen when an error occurs within our Lisp functions we have to create a new function that really rewrites the error process. So, the new function is named error and notice though that the error actually has asterisks at the beginning and the end. It is provided an argument, which is the message of the error. So if we create this and notice that I am in the A CAD doc Lisp that means every single time I go into a new drawing this error will be the error that is created or used if our Lisp functions fail. So what we can simply do is write anything inside that function. This allows us to reset variables…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.