Attribute Background Mask

Attribute Background Mask

tim_crouse
Collaborator Collaborator
1,978 Views
8 Replies
Message 1 of 9

Attribute Background Mask

tim_crouse
Collaborator
Collaborator

Does anyone have a lisp to toggle the background mask of a selected attribute in a standard and dynamic block (single line and multiline)

 

With a setting to use a background color and a 1.0 border?

 

If not does anyone have time to create such a lisp to toggle a selected lisp background mask?

 

Thanks in advance.

-Tim C.

0 Likes
1,979 Views
8 Replies
Replies (8)
Message 2 of 9

ВeekeeCZ
Consultant
Consultant

We can just automate things, not create properties that are not originally supported by the software itself.

Do all variants you want to have manually and post them here.

0 Likes
Message 3 of 9

tim_crouse
Collaborator
Collaborator

******

We can just automate things, not create properties that are not originally supported by the software itself.

Do all variants you want to have manually and post them here.

*****

 

Sorry but I do not understand your response.  Multiline attributes have a background property available through the attribute editor.(drop down arrow menu >> background mask).  I was hoping there was a way to do the following through a lisp:

1.  The user selects an attribute or launches the lisp then selects the attribute.

2.  The script then toggles the attribute background mask either to ON or to OFF

3.  A toggle ON would set the background mask boundary to 1.00 and the color to background.

4.  Toggle OFF turns the background mask off

 

Single line attributes DO NOT have a background property, I am assuming this is what you meant when it was mention that you can not add properties.

 

If there is something I can provide I will, do you need me to send a block with a multiline attribute with a background mask turned on?

 

Best Regards

-Tim C.

 

0 Likes
Message 4 of 9

tim_crouse
Collaborator
Collaborator

I came upon this code to toggle bgmask of MTEXT, was hoping this would help as a starter to work up a multiline attribute background mask toggle:

 

https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/turn-off-on-background-mask/td-p/938...

 

(defun c:togbm (/ cdrs ss cnt ent obj elst)

(defun cdrs (code lst) (cdr (assoc code lst)))

(setq ss (ssget ":L" '((0 . "MTEXT"))))

(cond (ss
(repeat (setq cnt (sslength ss))
(setq ent (ssname ss (setq cnt (1- cnt))))
(vlax-put-property (setq obj (vlax-ename->vla-object ent)) 'backgroundfill (if (= :vlax-true (vlax-get-property obj 'backgroundfill)) :vlax-false :vlax-true))
(cond ( (and (= :vlax-true (vlax-get-property obj 'backgroundfill)) (/= (cdrs 45 (setq elst (entget (vlax-vla-object->ename obj)))) 1.25))
(entmod (subst (cons 45 1.25) (assoc 45 elst) elst))
)
);end_cond
);end_repeat
)
( (alert "Nothing Selected"))
);end_cond
(princ)
);end_defun

0 Likes
Message 5 of 9

tim_crouse
Collaborator
Collaborator

I found another lisp that may provide a good framework too:

 

It's primary purpose is to remove formatting.  Perhaps it could be modified to toggle the backbround.

 

-Tim

0 Likes
Message 6 of 9

ВeekeeCZ
Consultant
Consultant

It seems that there is some issue with mask removal... HERE  can't figure out a way around it.

0 Likes
Message 7 of 9

Sea-Haven
Mentor
Mentor

This is getting a selection set of mtext (setq ss (ssget ":L" '((0 . "MTEXT")))) if you use Nentsel you can get at the actual attribute.

 

I like the link posted I am getting part success, can you post a sample dwg ?

 

 

(while (setq ent (nentsel "\nSelect an attribute "))
(setq elst (entget (car ent)))
(setq obj (vlax-ename->vla-object (car ent)))
(if (= :vlax-true (vlax-get-property obj 'backgroundfill))
 (princ)
 (vlax-put-property obj 'backgroundfill :vlax-true)
)
(entmod (subst (cons 45 1.25) (assoc 45 elst) elst))
)

 

 There is a variable somewhere about margin gap.

 

I had to set block to front via draworder to work.

0 Likes
Message 8 of 9

tim_crouse
Collaborator
Collaborator

Here is an example with a multiline attribute block.  One with a background mask, the other with a background mask off.

 

Thanks for working on this

-Tim C.

0 Likes
Message 9 of 9

john.uhden
Mentor
Mentor

@ВeekeeCZ 

I have never used multi-line attributes, but I see you have to define the attribute as having multiple lines.

I had tried modifying the textstring of a single-line attribute...

1.  (vlax-put attobj 'Textstring "One\\PTwo")

     -> "One\PTwo"

2. (vlax-put attobj 'Textstring "One\nTwo")

     -> "One

                  Two"

which is fine if you want to have a staggered string, but I think it's just a weird anomaly.

And the "\nTwo" doesn't show up in the attribute editor.  ☠️

John F. Uhden

0 Likes