Message 1 of 3
Mleader Styles and Settings - Update with LISP

Not applicable
12-21-2018
10:45 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I have this lisp routine that creates a mleader style but it doesn't change any of the settings such as text height, arrow sizes, etc. At the end of the lisp routine under "(list...", I thought these settings would update the mleader settings but it doesn't. Can anyone help? I'm not an expert in coding by any means.
Thanks
;;; ;;; Usage : (CreateMLeaderStyle [NewStyleName] [ConfigList]) ;;; Example: (CreateMLeaderStyle "Test" '(("TextStyle" . "Standard")("TextHeight" . 2.5))) ;;; ;;; [NewStyleName] - String -> Name of new MLeader Style ;;; [ConfigList] - List -> List with properties & values ;;; (defun CreateMLeaderStyle (CMS_NewName CMS_Config / CMS_TextStyle CMS_MLeaderStyles CMS_NewMLeaderStyle CMS_Property CMS_ColorObject) (if (or (and (setq CMS_TextStyle (cdr (assoc "TextStyle" CMS_Config))) (tblsearch "STYLE" CMS_TextStyle) ) (not (cdr (assoc "TextStyle" CMS_Config))) ) (progn (setq CMS_MLeaderStyles (vla-item (vla-get-Dictionaries (vla-get-ActiveDocument (vlax-get-acad-object))) "ACAD_MLEADERSTYLE")) (if (vl-catch-all-error-p (vl-catch-all-apply 'vla-item (list CMS_MLeaderStyles CMS_NewName))) (progn (setq CMS_NewMLeaderStyle (vla-AddObject CMS_MLeaderStyles CMS_NewName "AcDbMLeaderStyle")) (if (not (cdr (assoc "TextStyle" CMS_Config))) (vla-put-TextStyle CMS_NewMLeaderStyle (getvar "TEXTSTYLE")) ) (foreach CMS_Item CMS_Config (if (and (vl-consp CMS_Item) (= (type (setq CMS_Property (car CMS_Item))) 'STR) (not (listp (cdr CMS_Item))) (vlax-property-available-p CMS_NewMLeaderStyle CMS_Property) ) (cond ( (wcmatch (strcase CMS_Property) "*COLOR*") (setq CMS_ColorObject (vlax-get-property CMS_NewMLeaderStyle CMS_Property)) (vla-put-ColorIndex CMS_ColorObject (cdr CMS_Item)) (vl-catch-all-apply 'vlax-put-property (list CMS_NewMLeaderStyle CMS_Property CMS_ColorObject)) ) ( T (vl-catch-all-apply 'vlax-put-property (list CMS_NewMLeaderStyle CMS_Property (cdr CMS_Item))) ) ) ) ) (princ (strcat "\n ** Created " CMS_NewName " MLeader style")) (setvar "CMLEADERSTYLE" "STANDARD") ) (princ "\n ** Error: MLeader style already exists") ) ) (princ "\n ** Error: textstyle does not exist") ) (princ) ) (defun c:TEST () (CreateMLeaderStyle "STANDARD" (list '("ArrowSize" . 0.08) '("DoglegLength" . 0.035) '("LandingGap" . 0.08) '("LeaderLineColor" . 7) (cons "ScaleFactor" (getvar "DIMSCALE")) '("TextColor" . 7) '("TextHeight" . 0.08) '("TextLeftAttachmentType" . 1) '("TextRightAttachmentType" . 1) '("TextStyle" . "STANDARD") ) ) (princ) )