Jump to content

Multileader mask on


broncos15

Recommended Posts

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)
)

Link to comment
Share on other sites

(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 by marko_ribar
Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...