This is way better than my approach...
https://www.theswamp.org/index.php?topic=58809.0
(defun c:slot ( / cmd dict ent lastent obj prev ss vals vars *error*)
;; ----------------------------------------------------------- ;;
;; Draw Slot 29-11-2023 by dexus ;;
;; ----------------------------------------------------------- ;;
;; https://www.theswamp.org/index.php?topic=58809 ;;
;; ----------------------------------------------------------- ;;
;; Draw a slot with preview ;;
;; Prompts user for radius, startpoint and endpoint ;;
;; Global variable 'slot:rad' for last radius ;;
;; ----------------------------------------------------------- ;;
(defun *error* (msg)
(and vals (mapcar (function setvar) vars vals))
(or (wcmatch (strcase msg t) "*break,*cancel*,*exit*") (princ (strcat "\n* Error: " msg)))
(princ)
)
(setq vars '("cmdecho" "peditaccept" "qaflags")
vals (mapcar (function getvar) vars)
dict (cdar (dictsearch (namedobjdict) "acad_mlinestyle")))
(mapcar (function setvar) vars '(0 1 0))
(initget 6)
(if
(cond
((not
(setq slot:rad
(cond
((getdist (if (numberp slot:rad) (strcat "\nSpecify slot radius <" (rtos slot:rad 2 3) ">: ") "\nSpecify slot radius: ")))
(slot:rad)
)
))
(princ "\nNo slot radius chosen.") nil
)
((not (setq ent ; Create MLineStyle
(list
'(0 . "MLINESTYLE") '(100 . "AcDbMlineStyle") '(2 . "SLOT") '(70 . 1088) '(3 . "") '(51 . 1.5708) '(52 . 1.5708) '(71 . 2)
(cons 49 slot:rad) '(62 . 256) '(6 . "BYLAYER")
(cons 49 (- slot:rad)) '(62 . 256) '(6 . "BYLAYER")
)
)))
((setq prev (dictsearch dict "slot")) ; If Slot exists, entmod
(entmod (cons (assoc -1 prev) ent)) t
)
((dictadd dict "SLOT" (entmakex ent)) ; Otherwise create Slot
t
)
((princ "\nCreation of mline failed...") nil)
)
(progn
(setq lastent (entlast) cmd (getvar 'cmdecho))
(setvar 'cmdecho 0)
(princ "\nChoose first point: ")
(command "_mline" "_j" "_z" "_st" "SLOT" "\\") ; Create Mline
(princ "\nChoose end point: ")
(command "\\" "") ; Get endpoint of Mline
(if (not (equal lastent (setq obj (entlast))))
(progn
(setq lastent (entlast) ss (ssadd))
(command "_explode" obj) ; Explode Mline
(while (> (getvar "cmdactive") 0) (command ""))
(while (setq lastent (entnext lastent)) (ssadd lastent ss))
(command "_.pedit" "_m" ss "" "_j" "0.0" "") ; Convert to polyline
(setq ss nil)
)
)
(setvar 'cmdecho cmd)
)
)
(mapcar (function setvar) vars vals)
(princ)
)