rkent Posted April 11, 2012 Posted April 11, 2012 I cobbled together this lisp years ago to essentially offset just a part of a line and would like to make it better. The error trap doesn't seem to work. I would like to have it change to a layer of the object picked, or maybe another layer to be specified later. I imagine it can be cleaned up but I am not sure where to focus first. ;OffsetMeasure offset a short line (defun *error* (msg) (setvar "osmode" 0) (setq pt1 nil) (setq pt2 nil) (setq dist1 nil) (setq *seqpt nil) (princ "\n\n\nLeaving OM lisp routine, good day sir!\n") (princ) ) (defun C:OM (/ pt1 pt2 dist1 srt) (setvar "cmdecho" 0) (setq srt (getvar "sortents")) (setvar "sortents" 3) (graphscr) (setq d "T") (while d (if (not *seqpt)(setq *seqpt 1.0)) (princ "\nEnter Distance For Offset <") (princ *seqpt) (setq dist1 (getdist ">: ") ) (setvar "osmode" 512) (setq pt1 (getpoint "\nPick point on object :") pt2 (getpoint "\nSecond point :") ) (if (not dist1)(setq dist1 *seqpt)(setq *seqpt dist1) ) (setvar "osmode" 0) (command ".line" pt1 pt2 "") (princ "\nSide to offset") (command ".offset" dist1 pt1 pause "" ".erase" pt1 "" ".move" pt1 "" "@" "@") (setq d1 (strcase (getstring "\nPress RETURN to continue or X to quit "))) (if (= d1 "X")(setq d nil)) ) (setvar "sortents" srt) (princ) ) Any help would be appreciated. Point me in a direction or do it all for me, I don't have a preference. rkent Quote
BlackBox Posted April 11, 2012 Posted April 11, 2012 Having only skimmed your code, consider nesting the temporary *error* defun within the main code (c:OM), and be sure to localize the symbol so that once the main code completes the original *error* definition is restored. Pseudo code: (defun c:OM ( / *error* ;|Other vars| (defun *error* (msg) ;; <-- Your error handler here ) ;; <-- Main code here ) Quote
Lee Mac Posted April 11, 2012 Posted April 11, 2012 rkent, Maybe this tutorial of mine might help with the understanding: http://lee-mac.com/errorhandling.html Quote
BlackBox Posted April 11, 2012 Posted April 11, 2012 Renderman, that worked! Thanks, rkent @ Rkent - Happy to help. @ Lee - Well written tutorial, my friend. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.