In the latter option, the dotted line indicates the direction along a given angle, rather than following the cursor.
I apologize, but I and the author of the topic are Russian speakers, so I will repeat the answer in Russian.
В последнем варианте пунктирная линия указывает направление по заданному углу, а не бегает за курсором.
There is a slightly more optimised way to set and reset variables once you get more than about 2 or 3:
;;Include near the beginnin of the code:
(setq vars '("CMDECHO" "NOMUTT" "SNAPANG")) ;; Variables to change as a list
(setq old_Vars (mapcar 'getvar vars)) ;; get existing variable values
(mapcar 'setvar vars '(0 1 1)) ;; set variables to new values (in order of the list above)
;;Reset the variables
(mapcar 'setvar vars old_Vars)
Change to suit.
Added some convenience:
(defun c:11 (/ p0 ang dist)
(defun 11error (errormsg /)
(setvar "SNAPANG" old_snapang) ; reset variables
(setvar "ORTHOMODE" old_orthomode)
(setq *error* temperr) ; reset *error*
(prompt "\nFunction Canelled.")
)
(vl-load-com)
(setq p0 (getpoint "Pick the first point >")
ang (angtof (rtos (getreal "Enter angle >")) 0)
)
(setq Old_snapang (getvar "SNAPANG")) ; to record what it was, might not be 0
(setq old_orthomode (getvar "ORTHOMODE"))
(setq temperr *error*)
;store *error* ; can wait till here to set error function, after recording old variables
(setq *error* 11error)
(setvar "SNAPANG" ang)
(setvar "ORTHOMODE" 1)
(setq dist (distance p0 (getpoint p0 "Pick a second point >")))
(setvar "SNAPANG" Old_Snapang) ; moved this here, seto to old value (no assumption what it was)
(setvar "ORTHOMODE" old_orthomode)
(entmakex (list (cons 0 "LINE") (cons 10 p0) (cons 11 (polar p0 ang dist))))
(setq *error* temperr) ; reset error
(princ)
)
open up bother versions in their own notepad or similar and compare them side by side - a good way to learn, spot the difference and consider what was done and why?
Speed is always a compromise between loading and running the automation and doing it manually. For example if I had routines that I used once a year that took 1/10th second to load each then it might not be optimistic to load them on every drawing. If I had routines that I used in virtually every drawing then even that 1/10th second each it is well worth loading them,
BigAl usually has to hand or in his memory a line that loads a LISP on command, so you could type in '30' if the command isn't loaded then it is loaded. Makes opening drawings quicker (I think you need the LISPs in a trusted file location?).
Small change I'd make,
(defun c:11 (/ p0 ang dist)
(defun 11error ( errormsg / )
(setvar "SNAPANG" old_snapang) ; reset variables
(setq *error* temperr) ; reset *error*
(prompt "\nFunction Canelled.")
)
(vl-load-com)
(setq p0 (getpoint "Pick the first point >")
ang (angtof (rtos (getreal "Enter angle >")) 0)
)
(setq Old_snapang (getvar "SNAPANG") ) ; to record what it was, might not be 0
(setq temperr *error*) ;store *error* ; can wait till here to set error function, after recording old variables
(setq *error* 11error)
(setvar "SNAPANG" ang)
(setq dist (distance p0 (getpoint p0 "Pick a second point >")))
(setvar "SNAPANG" Old_Snapang) ; moved this here, seto to old value (no assumption what it was)
(entmakex (list (cons 0 "LINE") (cons 10 p0) (cons 11 (polar p0 ang dist))))
(setq *error* temperr) ; reset error
)