broncos15 Posted October 7, 2015 Share Posted October 7, 2015 I am trying to create a lisp that would turn on all the multileader masks. I know my error most likely has to do with turning the selection into something useable by visual lisp. If someone could explain what I am doing wrong, I would appreciate it as well because I want to learn. My code is as follows: (defun c:MASKON (/ sel1 sel2) ;Background Mask On (vl-load-com) (setq sel1 (ssget "X" '((0 . "MULTILEADER")))) (setq sel2 (vlax-ename->vla-object (sel1))) (vlax-put-property sel2 'BackgroundFill :vlax-true) (princ) ) Quote Link to comment Share on other sites More sharing options...
abra-CAD-abra Posted October 8, 2015 Share Posted October 8, 2015 Lee Mac's 'Mask' program works a treat: http://www.lee-mac.com/mask.html Thanks Lee Quote Link to comment Share on other sites More sharing options...
marko_ribar Posted October 8, 2015 Share Posted October 8, 2015 (edited) (defun c:maskmleaders ( / ss i ml ) (vl-load-com) (if (setq ss (ssget "_:L" '((0 . "MULTILEADER")))) (repeat (setq i (sslength ss)) (setq ml (vlax-ename->vla-object (ssname ss (setq i (1- i))))) (vla-put-textbackgroundfill ml :vlax-false) (vla-put-textbackgroundfill ml :vlax-true) ) (prompt "\nEmpty sel.set... Retry routine again...") ) (princ) ) You have to iterate through selection set of mleaders and set property to each of mleader individually... Also you'll have to check if selection set is valid and contain only mleaders that are on unlocked layer(s)... If you want to process all of them that are on thawed layer(s) and placed in current active space without manual selection, I suggest this : (defun c:maskmleaders-a ( / k n ss i ml ) (vl-load-com) (setq k 0 n 0) (if (setq ss (ssget "_A" (list '(0 . "MULTILEADER") (cons 410 (if (eq (getvar 'cvport) 1) (getvar 'ctab) "Model"))))) (progn (repeat (setq i (sslength ss)) (setq ml (vlax-ename->vla-object (ssname ss (setq i (1- i))))) (if (eq 4 (logand 4 (cdr (assoc 70 (tblsearch "LAYER" (vla-get-layer ml)))))) (setq k (1+ k)) (progn (vla-put-textbackgroundfill ml :vlax-false) (vla-put-textbackgroundfill ml :vlax-true) (setq n (1+ n)) ) ) ) (if (not (zerop n)) (prompt (strcat "\nTotal : " (itoa n) " MASK applied to MULTILEADERS...")) ) (if (not (zerop k)) (prompt (strcat "\nTotal : " (itoa k) " MULTILEADERS that are on locked layer(s) that couldn't have applied MASK to...")) ) ) (prompt "\nEmpty sel.set... No valid MULTILEADERS in database that are on thawed layer(s)... Retry routine again...") ) (princ) ) HTH, M.R. Edited October 8, 2015 by marko_ribar Quote Link to comment Share on other sites More sharing options...
broncos15 Posted October 8, 2015 Author Share Posted October 8, 2015 Thank you so much for the help! Is there an easy way to update the code so that it works for mtext and dimensions as well? I know to turn mtext background mask on it would be something like this (setq ss (ssget '((0 . "MTEXT")))) (if ss (mapcar '(lambda (x) (setq sel1 (vlax-ename->vla-object x)) (if (= (vla-get-backgroundfill sel1) :vlax-false) (vla-put-backgroundfill sel1 :vlax-true) ) ) However, I am unsure of how to combine this with your code and if dimension has the same variable for masking. I was thinking I would probably need another if statement enclosed within your function that differentiates if the selection is a multileader, mtext, or dimension. The issue for me is how to do this within visual lisp because I don't know what the objects are called once they have been converted to a vla object. Quote Link to comment Share on other sites More sharing options...
abra-CAD-abra Posted October 9, 2015 Share Posted October 9, 2015 For all new dimensions, explore: (setvar 'DIMTFILL 1) (setvar 'DIMTFILLCLR 256) For MTEXT, look here: http://autocadtips1.com/2011/08/19/autolisp-background-text-mask-mtext-only/; Cheers Quote Link to comment Share on other sites More sharing options...
marko_ribar Posted October 9, 2015 Share Posted October 9, 2015 I don't know if it can help you, but I wrote those inspired with this topic... M.R. maskmleaders.lsp maskdimensions.lsp maskmtexts.lsp Quote Link to comment Share on other sites More sharing options...
abra-CAD-abra Posted October 11, 2015 Share Posted October 11, 2015 Nice work, marko_ribar! Cheers, Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.