Message 1 of 7

Not applicable
11-04-2019
10:45 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi all,
I have pieced together a function (with several sub-functions I've found here - props to all other authors I borrowed from) to:
- Evaluate if a specific mleaderstyle exists in the drawing
- If it's present, change the Textstyle to Standard
Code:
(DEFUN RESETMLEADERS () ::**************************************** ;;function to test if mleaderstyle exists ::**************************************** (defun mLeaderstyleExist (styl / dict result) (if (setq dict (dictsearch (namedobjdict) "ACAD_MLEADERSTYLE")) (foreach x dict (if (and (= (car x) 3) (eq (strcase (cdr x)) (strcase styl)) ) (setq result t) ) ) ) result ) ::**************************************** ;;reset mleaderstyle "HEX-ARROW" ::**************************************** (defun RESEThexa () (setq dict (dictsearch (namedobjdict) "ACAD_MLEADERSTYLE") dict1 (member (cons 3 "HEX-ARROW") dict) el1 (entget (cdr (assoc 350 dict1))) er (tblobjname "style" "Standard") ) (entmod (subst (cons 342 er) (assoc 342 el1) el1)) ) ::**************************************** ;;reset mleaderstyle "HEX-DOT" ::**************************************** (defun RESEThexd () (setq dict (dictsearch (namedobjdict) "ACAD_MLEADERSTYLE") dict1 (member (cons 3 "HEX-DOT") dict) el1 (entget (cdr (assoc 350 dict1))) er (tblobjname "style" "Standard") ) (entmod (subst (cons 342 er) (assoc 342 el1) el1)) ) ::**************************************** ;;reset mleaderstyle "HEX-LOOP" ::**************************************** (defun RESEThexl () (setq dict (dictsearch (namedobjdict) "ACAD_MLEADERSTYLE") dict1 (member (cons 3 "HEX-LOOP") dict) el1 (entget (cdr (assoc 350 dict1))) er (tblobjname "style" "Standard") ) (entmod (subst (cons 342 er) (assoc 342 el1) el1)) ) ::**************************************** ;;reset mleaderstyle "HEX-TILDE" ::**************************************** (defun RESEThext () (setq dict (dictsearch (namedobjdict) "ACAD_MLEADERSTYLE") dict1 (member (cons 3 "HEX-TILDE") dict) el1 (entget (cdr (assoc 350 dict1))) er (tblobjname "style" "Standard") ) (entmod (subst (cons 342 er) (assoc 342 el1) el1)) ) ::**************************************** ;;check if mleaderstyle exists - if so, run its RESET function ::**************************************** (IF (mleaderstyleexist "HEX-ARROW") (RESEThexa) (PRINC) ) ;END IF ;;;__________________________________ (IF (mleaderstyleexist "HEX-DOT") (RESEThexd) (PRINC) ) ;END IF ;;;__________________________________ (IF (mleaderstyleexist "HEX-LOOP") (RESEThexl) (PRINC) ) ;END IF ;;;__________________________________ (IF (mleaderstyleexist "HEX-TILDE") (RESEThext) (PRINC) ) ;END IF ;;;__________________________________ ) ;end defun RESETMLEADERS
While this RESETMLEADERS function works, I think it could be done more efficiently by:
- passing a list of mleaderstyles to look for (instead of defining a ton of individual subfunctions)
- and for each that exists in the drawing
- set the textstyle to Standard.
The thing is, I'm not really strong with the syntax to pass/evaluate lists and doing something foreach.
If someone could point me in the direction of just the general structure of how to do this with mleaderstyles, I'd really appreciate it.
I understand that VLISP can be more efficient when working with mleaderstyles - but I'm even less proficient with VLISP.
Thanks so much!
Solved! Go to Solution.