Kinda crude but this is what I use:
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; This utility is for creating Dimension Styles 'on-the-fly' as
;; required by our utility 'my_LEADER' below.
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defun MakeDimStyle (/)
(SETVAR "CMDECHO" 0)
;;my_dimstylename my_leaderblock my_textstyle)
(setvar "DIMADEC" 0)
(setvar "DIMALTD" 2)
(setvar "DIMALTF" 25.4)
(setvar "DIMALTRND" 0)
(setvar "DIMALTTD" 2)
(setvar "DIMALTTZ" 0)
(setvar "DIMALTU" 2)
(setvar "DIMALTZ" 0)
(setvar "DIMAPOST" "")
(setvar "DIMASSOC" 2)
(setvar "DIMASZ" 0.125)
(setvar "DIMATFIT" 3)
(setvar "DIMAUNIT" 0)
(setvar "DIMAZIN" 0)
(setvar "DIMCEN" 0.0781)
(setvar "DIMCLRD" 0)
(setvar "DIMCLRE" 0)
(setvar "DIMCLRT" 0)
(setvar "DIMDEC" 4)
(setvar "DIMDLE" 0)
(setvar "DIMDLI" 0.0938)
(setvar "DIMDSEP" ".")
(setvar "DIMEXE" 0.0469)
(setvar "DIMEXO" 0.0469)
(setvar "DIMFIT" 3)
(setvar "DIMFRAC" 2)
(setvar "DIMGAP" 0.0781)
(setvar "DIMJUST" 0)
(setvar "DIMBLK" ".")
(setvar "DIMBLK1" ".")
(setvar "DIMBLK2" ".")
(setvar "DIMLFAC" 1)
(setvar "DIMLUNIT" 4)
(setvar "DIMLWD" -2)
(setvar "DIMLWE" -2)
(setvar "DIMPOST" "")
(setvar "DIMRND" 0)
(setvar "DIMSCALE" (getvar "ltscale"))
(setvar "DIMTAD" 0)
(setvar "DIMTDEC" 4)
(setvar "DIMTFAC" 1)
(setvar "DIMTM" 0)
(setvar "DIMTMOVE" 0)
(setvar "DIMTOLJ" 1)
(setvar "DIMTP" 0)
(setvar "DIMTSZ" 0)
(setvar "DIMTVP" 0)
(setvar "DIMTXSTY" my_textstyle)
(setvar "DIMTXT" 0.0781)
(setvar "DIMTZIN" 0)
(setvar "DIMUNIT" 6)
(setvar "DIMZIN" 0)
(setvar "DIMLDRBLK" my_leaderblock)
(command "-dimstyle" "s" my_dimstylename)
)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; my_LEADER
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; The purpose of this function is to create leaders based on company standard blocks and
;; layers with varying formats depending on the situation. The text is set, by default,
;; to a style called "DIMENSIONS". This could be changed in the future if it were ever
;; called for. Instructions for doing so are outlined within the code below.
;;
;; USAGE:
;;
;; (my_leader my_dimstyle my_leaderlayer my_leaderblock my_leaderformat)
;; -= or =-
;; (my_leader "my_Arrow" "ETEXT" "." "S")
;;
;; The example above would create a Dimension Style name "my_Arrow" and would draw a
;; curved leader on layer "ETEXT" with the default arrow at the end. Regarding the default
;; arrow, see the description of variable 'my_leaderblock' below.
;;
;; VARIABLES:
;;
;; my_dimstylename : Simply the name of the Dimension Style that you want to use. If it
;; does not already exist, the utility will create it for you.
;;
;; my_leaderlayer : The layer that you want the leaders to be drawn on. If the
;; specified layer does not exist, it will be created as a plain white
;; layer with a "CONTINUOUS" linetype.
;;
;; my_leaderblock : The name of the block that should appear at the end of your leader.
;; If the block is not already defined in the drawing, the utility will
;; attempt to find it. If the block is unable to be found an alert box
;; will warn the user that the block can't be loaded and the utility
;; will halt. If the block should be the default arrow, "." should be
;; specified as the block name.
;;
;; my_leaderformat : The format of the leader lines. Acceptable values for this variable
;; are as follows:
;; S = Splined (curved) lines
;; ST = Straight lines
;; A = Arrow. Puts a block at the end of the leader (default)
;; N = None. Eliminates the block at the end of the leader
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; (defun my_leader (my_dimstylename my_leaderlayer my_leaderblock my_leaderformat /)
(defun my_leader (my_dimstylename my_leaderlayer my_leaderblock my_leaderformat my_textstyle /)
;;
;; Comment out the first line of this function and un-comment the second to enable the use
;; of varying text styles. There's more to edit below.
(setvar "LUNITS" 4) ;; Set the units to 'Architectural' by default.
(if (= (DimStyle-Exists my_dimstylename) nil) ;; Check to see that the Dimension Style exists.
(progn ;; If it doesn't exist, let's create it using the other variables specified.
(if (and (/= my_leaderblock ".") ;; First, let's see if we have the specified block.
(not (tblsearch "block" my_leaderblock))
)
(progn ;; If not, let's look for it
(if (findfile (strcat my_leaderblock ".dwg"))
(progn ;; If we find it, let's insert it in the drawing
(command "-insert" my_leaderblock "0,0" "" "" "")
(princ
)
(command ".erase" (entlast) "") ;; Then we erase it. No point having a stray block in there.
) ;_ end progn
(progn ;; This is what happens in the event that the block didn't exist in the drawing and
;; it couldn't be found in the AutoCAD Path. Tell the user that it doesn't exist as
;; far as AutoCAD can tell.
(alert
(strcat " The block "
my_leaderblock
" cannot be found, "
"\n the leader cannot be created. "
) ;_ end strcat
) ;_ end alert
(exit) ;; Then exit the utility altogether
) ;_ end progn
) ;end if
) ;end progn
) ;end if
;;; <<<<----==== BEGIN TEXT STYLE MODIFICATIONS HERE ====---->>>>
;;; (if (= (TxtStyle-Exists "DIMENSIONS") nil)
;;; (command "-style" "DIMENSIONS" "simplex" "0" "1.0" "0.0" "n" "n" "n")
;;; (setvar "textstyle" "DIMENSIONS")
;;; )
(if (= (TxtStyle-Exists my_textstyle) nil)
(command "-style" my_textstyle "simplex" "0" "1.0" "0.0" "n" "n" "n" )
(setvar "textstyle" my_textstyle)
)
;;; <<<<----===== END TEXT STYLE MODIFICATIONS HERE =====---->>>>
;;;
;;; Comment out the first four lines of the above code between BEGIN and END then
;;; uncomment the last four lines of code to enable the use of varying text styles.
;;; If the specified text style does not exist in the drawing it will be created
;;; with a default setup of 'SIMPLEX' text that can be changed at a later time by
;;; issuing the 'STYLE' command in AutoCAD.
;;;
;;; This will change the format of the command when you issue it to
;;; (my_dimstylename my_leaderlayer my_leaderblock my_leaderformat my_textstyle)
;;; where 'my_textstyle' is the name of the style you wish to use.
;;;
(MakeDimStyle) ;;; Since our Dimension Style didn't exist, issue the MakeDimStyle
;;; command to create it.
)
(command "-dimstyle" "r" my_dimstylename) ;; Make sure that, since our Dimension
;; Style DID exist, that we switch to
;; it before proceeding.
)
(if (= (Layer-Exists my_leaderlayer) nil) ;; Check to see that the specified layer
;; actually exists
(command "-layer" "n" my_leaderlayer "c" "7" my_leaderlayer "") ;; If it doesn't
(command "-layer" "s" my_leaderlayer "") ;; If it does
)
(setvar "dimscale" (getvar "ltscale")) ;; Adjust the DIMSCALE to match the LTSCALE
(popin 0 512 nil 2)
(setq pt1 (getpoint "\nFirst point...")) ;; Begin drawing our leader
(setq pt2 (getpoint pt1 "\nNext point..."))
(command "_leader" pt1 pt2 "F" my_leaderformat) ;; Format the leader as spcified.
(popout)
(princ)
) ;_ end defun my_leader