guitarguy1685 Posted December 30, 2009 Posted December 30, 2009 I'm practicing my lisp skill by making a Lisp that will create a metal angel given two leg lengths and thickness. When I start a new drawing and start the lisp it doesn't draw my angle correctly at all. However if I try it again it works! why would it not work on the first try? Here is my Lisp. and a pic. On the left is my first time running the list, on the right is the 2nd time. Nothing changed. (defun C:AN () (setq Oldecho (getvar "cmdecho")) (setvar "cmdecho" 0) (setq AB (getpoint "\nSelect Base Point: ")) ;;;Base Point (setq AL1 (getdist "\nSpecify size of first leg: ")) ;;;Leg 1 (setq AL2 (getdist "\nSpecify size of second leg: ")) ;;;Leg 2 (setq AW (getdist "\nSpecify thickness: ")) ;;;Thickness (setq P1 (list (+ (car AB) AL1) (cadr AB))) (setq P2 (list (- (car P1) AL1) (cadr P1))) (setq P3 (list (car P2) (+ (cadr P2) AL2))) (setq P4 (list (+ (car P3) AW) (cadr P3))) (setq P5 (list (car P4) (- (cadr P4) (abs (- AL2 AW))))) (setq P6 (list (+ (car P5) (abs (- AL1 AW))) (cadr P5))) (command "_.pline" P1 P2 P3 P4 P5 P6 "close") (setvar "cmdecho" Oldecho) (princ) ) Quote
CarlB Posted December 30, 2009 Posted December 30, 2009 It may be you have an endpoint OSNAP enabled, so instead of drawing to specified point it snaps to endpoint. Zoom level affects this, so erratic behavior. If this it, you may want to to add lines at beginning to save user osmode, then set osmode to 0, as in (setvar "OSMODE" 0) then restore setting at end. Quote
guitarguy1685 Posted December 30, 2009 Author Posted December 30, 2009 I think you might be right Quote
guitarguy1685 Posted December 30, 2009 Author Posted December 30, 2009 so far it seems to have workd. Thank you kind sir Quote
Lee Mac Posted December 30, 2009 Posted December 30, 2009 I would recommend adding an Error Handler to the code when you are messing with OSMODE (and CMDECHO for that matter). I know how annoying it is when codes reset your OSNAPs... Example: http://www.cadtutor.net/forum/showpost.php?p=290564&postcount=2 A few more: http://www.afralisp.net/lispa/lisp6.htm http://www.cadtutor.net/forum/showthread.php?t=33966 http://www.cadtutor.net/forum/showpost.php?p=261049&postcount=3 Quote
guitarguy1685 Posted December 31, 2009 Author Posted December 31, 2009 that's a great idea. I did notice that my osnap was being blanked. I'm going to use (defun *error* (msg) (if oldCM (setvar "CMDECHO" oldCM)) (if oldos (setvar "OSMODE" oldos)) (princ msg) (princ)) it seems simple enough, thanks a bunch. 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.