This lisp routine I have used for ages but skipped a view versions and I'm trying to use with 2018 and 2021 is no longer functioning as it used to. The expected functionality is during the block placement, we pick a second point using the nearest osnap to align the block with the line so that the block is aligned with 2nd point we pick and then the block is inserted. Any help is greatly appreciated.
Code:
;|Routine to label contours drawn by Line/Arc/Polyline. Originally penned by
CiphDRMRS, aka T.Willey, on the AUGI Forums. Modified by Jeff Mishler.
An assumption is made that a valid block with 1 attribute is selected.
|;
(vl-load-com)
(defun c:CLB ( / *error* osz atq atd cmd e p)
(defun *error* (errmsg)
(if (not (wcmatch errmsg "Function cancelled,quit / exit abort,console break,end"))
(princ (strcat "\nError: " errmsg)))
(if osz (setvar 'osnapz osz))
(if atq (setvar 'attreq atq))
(if atd (setvar 'attdia atd))
(if cmd (setvar 'cmdecho cmd))
(princ))
(setq osz (getvar 'osnapz)) (setvar 'osnapz 0)
(setq atq (getvar 'attreq)) (setvar 'attreq 0)
(setq atd (getvar 'attdia)) (setvar 'attdia 0)
(setq cmd (getvar 'cmdecho)) (setvar 'cmdecho 0)
(while (and (setq p (getpoint "\nPlace a label: "))
(setq e (car (nentselp p))))
(command "_.insert" "CL3-20"
"_S" 1
"_R" (angtos (angle '(0 0 0) (vlax-curve-getFirstDeriv e (vlax-curve-getParamAtPoint e (vlax-curve-getclosestpointto e p)))) (getvar 'aunits) 8)
"_nea" p)
(setpropertyvalue (entlast) "CLAB" (rtos (last p) 2 0)))
(*error* "end")
)