As promised, here is more, for some reason when I put the style to the leader, the leader always ends at 0,0, does anyone have an idea as to why?
(defun c:uleader (/ *ThisDrawing* *Space* *Scale* *IsCivil* *Path* *Prompt* *Align* *Match* *Types* *Style* *POC* *POCS* *Typ* *Note* *NewPoints* *MlObj* Pt1 Pt2 FxPt Input Data Code Ent1 POS Pt1Tst)
(vl-cmdf "._-insert" "Uleader.dwg")(command); Insert in leader styles
(setq *Types* (LIST "MTEXT" "1M08" "PL08" "AH08" "CFM" "FXU" "GPM" "PANEL" "FEEDER")
*POCS* (list nil "-Poc" "-Pod")
)
(vl-load-com)
;Supporting Functions
(defun eraseold (obj /) ;Erases the previous version of a VLA object - Code modifcation provided by ronjonp at http://www.theswamp.org/index.php?topic=54340.msg589085#msg589085
(and (= 'vla-object (type obj))
(not (vlax-erased-p obj))
(vlax-write-enabled-p obj)
(vla-delete obj)
)
)
(defun GetVportScale ()
(/ 1 (vla-get-CustomScale (vla-get-ActivePViewport (vla-get-activedocument (vlax-get-acad-object)))))
)
(defun PolarRound (ang deg)
(* (/ pi (/ 180 (r2d deg))) (fix (/ (+ (/ pi (/ 360 (r2d deg))) ang) (/ pi (/ 180 (r2d deg))))))
)
(defun D2R (numberOfDegrees)
(* pi (/ numberOfDegrees 180.0))
) ;_ end of defun
(defun R2D (nbrOfRadians)
(* 180.0 (/ nbrOfRadians pi))
)
;End of Supporting Functions
(setq *Path* (getvar "dwgprefix")
*ThisDrawing* (vla-get-activedocument (vlax-get-acad-object)) ;_ Set Drawing and Space
*Space* (vlax-get-property *ThisDrawing* (if (= 1 (getvar 'cvport)) 'paperspace 'modelspace)); Code adjustment from Lee Mac at: http://www.theswamp.org/index.php?topic=54349.msg589159#msg589159
*Scale* (if (zerop (vla-get-activespace *ThisDrawing*))
(if (= (vla-get-mspace *ThisDrawing*) :vlax-true)
(GetVportScale)
1.0
)
(getvar "DimScale")
)
)
(setq newpoints (vlax-make-safearray vlax-vbDouble '(1 . 6)))
(If (> (strlen *path*) 5);Determine if this is a civil drawing
(progn
(setq pos (vl-string-position (ascii "\\") *Path* (+ (vl-string-position (ascii "\\") *path* 5) 1)))
(If (or (= (strcase (substr *path* (+ pos 8) 1)) "C") (= (getvar "USERS5") "CIVIL"))
(setq *IsCivil* T)
)
)
)
(if (zerop (vla-get-activespace *ThisDrawing*)); Set scale
(if (= (vla-get-mspace *ThisDrawing*) :vlax-true)
(setq *Scale* (GetVportScale))
(setq *Scale* 1.0)
)
(setq *Scale* (getvar "DimScale"))
)
(vla-StartUndoMark *ThisDrawing*)
;ERROR HANDLER
(defun *error* (msg)
(if mlObj
(progn
(vla-highlight mlObj :vlax-false)
(EraseOld mlObj)
)
)
;; Added by Pkenewell on 3/28/2014
(vla-EndUndoMark *ThisDrawing*)
(or (wcmatch (strcase msg) "*BREAK,*CANCEL*,*EXIT*")
(princ (strcat "\n** Error: " msg " **"))
)
(princ)
)
(if (not (tblsearch "LAYER" "LEADER")) ; Check to see if layer exists
(if (= 1 (getvar "pstylemode"))
(command "._-layer" "n" "LEADER" "color" "WHITE" "" "lweight" "DEFAULT" "" "ltype" "CONTINUOUS" "" "")
(command "._-layer" "n" "LEADER" "color" "WHITE" "" "lweight" "DEFAULT" "" "ltype" "CONTINUOUS" "" "pstyle" "BLACK" "" "")
)
)
(setvar "annoautoscale" 4)
(while (not Pt1)
(initget "Select _Select")
(setq Pt1 (getpoint "\nPick starting point of leader [Select leader]:"))
(cond
((= Pt1 "Select")
(while (not Ent1)
(setq Ent1 "\nSelect leader to modify or align to:")
(if (not Ent1)
(princ "\r*** You must select a leader ***")
)
(setq Pt1 (cadr Ent1))
)
)
)
)
(vlax-safearray-put-element newpoints 1 (car pt1))
(vlax-safearray-put-element newpoints 2 (cadr pt1))
(vlax-safearray-put-element newpoints 3 (caddr pt1))
(if (not Ent1)
(setq Ent1 (nentselp "" Pt1))
)
(if Ent1
(if (/= (cdr (assoc 0 (entget (car Ent1)))) "MULTILEADER")
(progn
(setq *STYLE* "BEIOB-R1"
Ent1 nil
)
)
(setq *STYLE* "BEINOB-R1")
)
(setq *STYLE* "BEINOB-R1")
)
(if Ent1
(progn ;If existing leader is selected allow for modifying or aligning to the leader
(princ "\nAdd code for modifying/aligning leader here")
)
(progn ;If existing leader is not selected, draw a new leader
(while (not Pt2)
(if (or (not *Content*) (= *Content* ""))
(setq *Content* (nth 0 *Types*))
)
(If (= *Content* "MTEXT")
(progn
(if *IsCivil*
(setq *Arrowheads* (list "CIVIL" "BEIOB-R1" "BEINOB-R1" "BOX-R1" "LOOP-R1" "BEISPL"))
(setq *Arrowheads* (list "BEIOB-R1" "BEINOB-R1" "BOX-R1" "LOOP-R1" "BEISPL"))
)
)
(progn
(if *IsCivil*
(setq *Arrowheads* (list "CIVIL" "BEIOB-R1" "BEINOB-R1" "BOX-R1" "LOOP-R1"))
(setq *Arrowheads* (list "BEIOB-R1" "BEINOB-R1" "BOX-R1" "LOOP-R1"))
)
)
)
(setq *Prompt* (strcat "\rSpecify second point [Content (" *Content* ")"))
(if (or (not *Style*) (= *Style* ""))
(setq *Style* (nth 0 *Arrowheads*))
)
(if (and (/= *Content* "1M08") (/= *Content* "MTEXT"))
(progn
(if *Note*
(setq *Prompt* (strcat *Prompt* "/** Note **"))
(setq *Prompt* (strcat *Prompt* "/Note"))
)
)
)
(if (/= *Content* "MTEXT")
(progn
(if *Typ*
(setq *Prompt* (strcat *Prompt* "/** Typical **"))
(setq *Prompt* (strcat *Prompt* "/Typical"))
)
)
)
(if (not *POC*)
(setq *Prompt* (strcat *Prompt* "/Poc(d)"))
(setq *Prompt* (strcat *Prompt* "/" (substr *POC* 2)))
)
(setq *prompt* (strcat *Prompt* "/Arrowheads (" *Style* ")]:"))
(if *Align*
(setq *Prompt* (strcat *Prompt* " " *Align*))
)
(if *Match*
(setq *Prompt* (strcat *Prompt* " " *Match*))
)
(princ *Prompt*)
(setq Input (grread t 4 4)
Data (cadr Input)
Code (car Input)
)
(cond
((= Code 2);Handle all keypresses
(cond
((= data 15); Change Orthomode when F8 is pressed
;Code adjustment from Lee at http://www.theswamp.org/index.php?topic=54349.msg589159#msg589159
(setvar 'orthomode (- 1 (getvar 'orthomode)))
)
((= data 21); Toggle Polarmode when F10 is pressed
;Code adjustment from Lee at http://www.theswamp.org/index.php?topic=54349.msg589159#msg589159
(setvar 'autosnap (boole 6 8 (getvar 'autosnap)))
)
((or (= data 65) (= data 97)); Change arrowheads when A is pressed
(setq POS (vl-position *Style* *Arrowheads*))
(if (< POS (length *Arrowheads*))
(setq *Style* (nth (+ POS 1) *Arrowheads*))
(setq *Style* (nth 0 *Arrowheads*))
)
)
((or (= data 67) (= data 99)); Change content when C is pressed
(setq POS (vl-position *Content* *Types*))
(if (< POS (length *Types*))
(setq *Content* (nth (+ POS 1) *Types*))
(setq *Content* (nth 0 *Types*))
)
)
((or (= data 80) (= data 112)); Cycle through Point of connection/disconnection when P is pressed
(setq POS (vl-position *POC* *POCS*))
(if (< POS (length *POCS*))
(setq *POC* (nth (+ POS 1) *POCS*))
(setq *POC* (nth 0 *POCS*))
)
)
((and (or (= data 78) (= data 110)) (/= *Content* "1M08") (/= *Content* "MTEXT")); Change Note when N is pessed
(if *Note*
(setq *Note* nil)
(setq *Note* T)
)
)
((and (or (= data 84) (= data 116)) (/= *Content* "MTEXT")); Change Typical when T is pessed
(if *Typ*
(setq *Typ* nil)
(setq *Typ* T)
)
)
)
)
((= Code 5)
(setq FxPt (trans data 1 0))
(EraseOld *MlObj*)
(vlax-safearray-put-element newpoints 4 (car FxPt))
(vlax-safearray-put-element newpoints 5 (cadr FxPt))
(vlax-safearray-put-element newpoints 6 (caddr FxPt))
(setq *MlObj* (vla-AddMleader *Space* newpoints 0))
(vla-put-stylename *MlObj* *Style*);Something appears to be wrong with this line, it causes the leader to always end at 0,0
(vla-put-layer *MlObj* "LEADER")
)
)
)
)
)
(vla-EndUndoMark *ThisDrawing*)
)