Here's my version. Commands BDim and BdimSet. You can adjust defaults as prefered.
HTH
(vl-load-com)
(defun c:BDimSet nil (BDimSet) (c:BDim) (princ))
(defun BDimSet nil
(setq *bd-type* "Both") ; default type
(setq *bd-offset* 30.) ; default offset
(initget "Ordinate Continuous Both")
(setq *bd-type* (cond ((getkword (strcat "\nSpecify DIM type [Ordinate/Continuous/Both] <" *bd-type* ">: ")))
(*bd-type*)))
(setq *bd-offset* (cond ((getdist (strcat "\nSpecify offset <" (rtos *bd-offset* 2) ">: ")))
(*bd-offset*)))
(and *bd-type* *bd-offset*))
; ---------------------------------------------------------------------------------------------------------
(defun c:BDim (/ *error* doc das LM:ssboundingbox ss sl bb mr mt ml mb sp i ed ep lp)
(defun *error* (errmsg)
(if (not (wcmatch errmsg "Function cancelled,quit / exit abort,console break,end"))
(princ (strcat "\nError: " errmsg)))
(if lp (mapcar 'entdel lp))
(if das (setvar 'dimassoc das))
(if doc (vla-endundomark doc))
(princ))
;; Selection Set Bounding Box - Lee Mac ;; http://www.lee-mac.com/ssboundingbox.html
(defun LM:ssboundingbox ( sel / idx llp ls1 ls2 obj urp )
(repeat (setq idx (sslength sel))
(setq obj (vlax-ename->vla-object (ssname sel (setq idx (1- idx)))))
(if (and (vlax-method-applicable-p obj 'getboundingbox)
(not (vl-catch-all-error-p (vl-catch-all-apply 'vla-getboundingbox (list obj 'llp 'urp)))))
(setq ls1 (cons (vlax-safearray->list llp) ls1)
ls2 (cons (vlax-safearray->list urp) ls2))))
(if (and ls1 ls2)
(mapcar '(lambda ( a b ) (apply 'mapcar (cons a b))) '(min max) (list ls1 ls2))))
(if (and (or (and *bd-type* *bd-offset*)
(BDimSet))
(princ (strcat "\nCurrent setting: Type=" *bd-type* ", Offset=" (rtos *bd-offset* 2) ". Call 'BDimSet' for reset."))
(setq ss (ssget '((0 . "INSERT,LINE"))))
(setq sl (ssget "_P" '((0 . "LINE"))))
(setq bb (LM:ssboundingbox sl))
(setq mr (list (caadr bb) (/ (+ (cadar bb) (cadadr bb)) 2))) ; right
(setq mt (list (/ (+ (caar bb) (caadr bb)) 2) (cadadr bb))) ; top
(setq ml (list (caar bb) (/ (+ (cadar bb) (cadadr bb)) 2))) ; left
(setq mb (list (/ (+ (caar bb) (caadr bb)) 2) (cadar bb))) ; bottom
(setq sp (ssadd))
(setq das (getvar 'dimassoc))
(setvar 'dimassoc 1)
)
(progn
(vla-startundomark (setq doc (vla-get-activedocument (vlax-get-acad-object))))
(repeat (setq i (sslength ss))
(and (setq ed (entget (ssname ss (setq i (1- i)))))
(= "INSERT" (cdr (assoc 0 ed)))
(setq ep (entmakex (list '(0 . "POINT") (assoc 10 ed))))
(ssadd ep sp)
(setq lp (cons ep lp))))
(if (wcmatch *bd-type* "Continuous,Both")
(command "_.qdim" sl sp "" "_c" (mapcar '+ (trans ml 0 1) (list (- *bd-offset*) 0))
"_.qdim" sl sp "" "_c" (mapcar '+ (trans mb 0 1) (list 0 (- *bd-offset*)))
"_.qdim" sl "" "_c" (mapcar '+ (trans mr 0 1) (list *bd-offset* 0))
"_.qdim" sl "" "_c" (mapcar '+ (trans mt 0 1) (list 0 *bd-offset*))))
(if (wcmatch *bd-type* "Ordinate,Both")
(command "_.qdim" sl sp "" "_p" "_non" (trans (car bb) 0 1) "_o" "_non" (mapcar '+ (trans ml 0 1) (list (- (* 2 *bd-offset*)) 0))
"_.qdim" sl sp "" "_o" "_non" (mapcar '+ (trans mb 0 1) (list 0 (- (* 2 *bd-offset*))))
"_.qdim" sl "" "_o" "_non" (mapcar '+ (trans mr 0 1) (list (* 2 *bd-offset*) 0))
"_.qdim" sl "" "_o" "_non" (mapcar '+ (trans mt 0 1) (list 0 (* 2 *bd-offset*)))))
))
(*error* "end")
)