Jump to content

Attribute w/ Background Mask


Pineapple

Recommended Posts

Just make sure the variable is on when you execute the routine.

 

Alan, I remember seeing a lisp I think you wrote to match value from a attribute to another, or from mtext to attribute or any combination between text, mtext and attribute... Does that one work for this kind of multiline attribute?

 

---------------------

 

NOUP.... i got confused... it's the TAM.lsp from terry Miller what I thought was yours..

 

http://web2.airmail.net/terrycad/AutoLISP-Code.htm

 

and it doesn´t work with these type of multiline attribute ... I guess it's possible to add that code you post in this thread... but well.. we'll see later

Link to comment
Share on other sites

  • Replies 25
  • Created
  • Last Reply

Top Posters In This Topic

  • alanjt

    6

  • gilsoto13

    5

  • Pineapple

    3

  • rhatx

    3

Alan, I remember seeing a lisp I think you wrote to match value from a attribute to another, or from mtext to attribute or any combination between text, mtext and attribute... Does that one work for this kind of multiline attribute?

 

---------------------

 

NOUP.... i got confused... it's the TAM.lsp from terry Miller what I thought was yours..

 

http://web2.airmail.net/terrycad/AutoLISP-Code.htm

 

and it doesn´t work with these type of multiline attribute ... I guess it's possible to add that code you post in this thread... but well.. we'll see later

 

 

Mine does now. :)

http://www.cadtutor.net/forum/showthread.php?p=270690#post270690

Link to comment
Share on other sites

  • 2 weeks later...
merry christmas :)

;;; ------------------------------------------------------------------------
;;;    TextMaskToggle.lsp v1.2
;;;
;;;    Copyright© 03.10.09
;;;    Alan J. Thompson (alanjt)
;;;
;;;    Permission to use, copy, modify, and distribute this software
;;;    for any purpose and without fee is hereby granted, provided
;;;    that the above copyright notice appears in all copies and
;;;    that both that copyright notice and the limited warranty and
;;;    restricted rights notice below appear in all supporting
;;;    documentation.
;;;
;;;    Allows user to toggle the Textmask state of selected
;;;    Mtext and/or Multileaders.
;;;
;;;    Revision History:
;;;
;;;    v1.1 (03.16.09) Added ability to set offset (default is 1.0)
;;;    v1.2 (05.25.09) Minor cosmetic changes to coding and updated
;;;            subroutines.
;;;
;;; ------------------------------------------------------------------------

(defun c:TGM (/) (c:TextmaskToggle))
(defun c:TextMaskToggle (/             *error*       AT:SS->List
                        AT:Undo       #BackgroundOffset
                        #SSList       #Object       #Ent
                       )

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;; SUBROUTINES ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;;;error handler
 (defun *error* (msg)
   (AT:Undo "V" "E")
   (if
     (not
       (member
         msg
         '("console break" "Function cancelled" "quit / exit abort")
       ) ;_ member
     ) ;_ not
      (princ (strcat "\nError: " msg))
   ) ;_ if
 ) ;_ defun


;;; Convert selection set to list of ename or vla objects
;;; #Selection - SSGET selection set
;;; #VLAList - T for vla objects, nil for ename
;;; Alan J. Thompson, 04.20.09
 (defun AT:SS->List (#Selection #VlaList / #List)
   (and #Selection
        (setq #List (vl-remove-if
                      'listp
                      (mapcar 'cadr (ssnamex #Selection))
                    ) ;_ vl-remove-if
        ) ;_ setq
        (if #VlaList
          (setq #List (mapcar 'vlax-ename->vla-object #List))
        ) ;_ if
   ) ;_ and
   #List
 ) ;_ defun


;;; Undo Begin/End (Either VLA or Command)
;;; #CommandVLA - "V" for VLA OR "C" for Command
;;; #BeginEnd - "B" for Undo Begin OR "E" for Undo End
;;; Alan J. Thompson, 03.23.09
(defun AT:Undo (#CommandVLA #BeginEnd / #OldCmdecho)
 (if
   (and
     (member (strcase #CommandVLA) (list "C" "V"))
     (member (strcase #BeginEnd) (list "B" "E"))
   ) ;_ and
    (cond
      ;; COMMAND Undo Options
      ((eq "C" (strcase #CommandVLA))
       (setq #OldCmdecho (getvar "cmdecho"))
       (setvar "cmdecho" 0)
       (cond
         ;; Undo Begin
         ((eq "B" (strcase #BeginEnd)) (command "_.undo" "_begin"))
         ;; Undo End
         ((eq "E" (strcase #BeginEnd)) (command "_.undo" "_end"))
       ) ;_ cond
       (setvar "cmdecho" #OldCmdecho)
      )
      ;; VLA Undo Options
      ((eq "V" (strcase #CommandVLA))
       (cond
         ;; Undo Begin
         ((eq "B" (strcase #BeginEnd))
          (vla-StartUndoMark
            (vla-get-ActiveDocument
              (vlax-get-Acad-Object)
            ) ;_ vla-get-ActiveDocument
          ) ;_ vla-StartUndoMark
         )
         ;; Undo End
         ((eq "E" (strcase #BeginEnd))
          (vla-EndUndoMark
            (vla-get-ActiveDocument
              (vlax-get-Acad-Object)
            ) ;_ vla-get-ActiveDocument
          ) ;_ vla-EndUndoMark
         )
       ) ;_ cond
      )
    ) ;_ cond
 ) ;_ if
) ;_ defun


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;; MAIN ROUTINE ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

 (vl-load-com)

 (AT:Undo "V" "B")
 ;; background offset setting
 (setq #BackgroundOffset 1.0)

 (cond
   ;; select mtext and multileaders
   ((setq #SSList
           (AT:SS->List (ssget ":L" '((0 . "MTEXT,MULTILEADER"))) T)
    ) ;_ setq
    ;; something selected, time to process data
    (mapcar
      '(lambda (x)
         (cond
           ;; mtext
           ((eq (vla-get-ObjectName x) "AcDbMText")
            (if (eq (vla-get-backgroundfill x) :vlax-false)
              (progn
                ;; set backgroundfill to true
                (vla-put-backgroundfill x :vlax-true)
                ;; convert object to ename and entmod offset
                (setq #Ent (entget (vlax-vla-object->ename x)))
                (entmod (subst (cons 45 #BackgroundOffset)
                               (assoc 45 #Ent)
                               #Ent
                        ) ;_ subst
                ) ;_ entmod
              ) ;_ progn
              ;; set backgroundfill to false
              (vla-put-backgroundfill x :vlax-false)
            ) ;_ if
           )
           ;; multileader
           ((eq (vla-get-Objectname x) "AcDbMLeader")
            (if (eq (vla-get-TextBackgroundFill x) :vlax-false)
              (progn
                ;; set background fill to true
                (vla-put-TextBackgroundFill x :vlax-true)
                ;; convert object to ename and entmod offset
                (setq #Ent (entget (vlax-vla-object->ename x)))
                (entmod (subst (cons 141 #BackgroundOffset)
                               (assoc 141 #Ent)
                               #Ent
                        ) ;_ subst
                ) ;_ entmod
              ) ;_ progn
              ;; set backgroundfill to false
              (vla-put-TextBackgroundFill x :vlax-false)
            ) ;_ if
           )
         ) ;_ cond
       ) ;_ lambda
      #SSList
    ) ;_ mapcar
   )
 ) ;_ cond

 (AT:Undo "V" "E")

 (princ)
) ;_ defun

 

Hey, I was wondering... (wondering again), that we have 3 different options for masking objects, Backgroung mtext, wipeout dtext and lately I found a Vlx called Dimmask.vlx to mask temporarily selected dimensions' text.

 

Wouldn´t it be good to have a "mask.lsp" to mask all dims, text, and mtext at once.. but I think it is preferable to use background mask for mtext, so from selected objects, the lisp will have to decide if mtext, apply the background mask, if normal text, use wipeout and if it's dimension... well.. I am not sure... but I think that lisp uses a mask for them... have you thought about it before?

Edited by gilsoto13
Link to comment
Share on other sites

  • 3 weeks later...
merry christmas :)

;;; ------------------------------------------------------------------------
;;;    TextMaskToggle.lsp v1.2
;;;
;;;    Copyright© 03.10.09
;;;    Alan J. Thompson (alanjt)
;;;
;;;    Permission to use, copy, modify, and distribute this software
;;;    for any purpose and without fee is hereby granted, provided
;;;    that the above copyright notice appears in all copies and
;;;    that both that copyright notice and the limited warranty and
;;;    restricted rights notice below appear in all supporting
;;;    documentation.
;;;
;;;    Allows user to toggle the Textmask state of selected
;;;    Mtext and/or Multileaders.
;;;
;;;    Revision History:
;;;
;;;    v1.1 (03.16.09) Added ability to set offset (default is 1.0)
;;;    v1.2 (05.25.09) Minor cosmetic changes to coding and updated
;;;            subroutines.
;;;
;;; ------------------------------------------------------------------------

(defun c:TGM (/) (c:TextmaskToggle))
(defun c:TextMaskToggle (/             *error*       AT:SS->List
                        AT:Undo       #BackgroundOffset
                        #SSList       #Object       #Ent
                       )

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;; SUBROUTINES ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;;;error handler
 (defun *error* (msg)
   (AT:Undo "V" "E")
   (if
     (not
       (member
         msg
         '("console break" "Function cancelled" "quit / exit abort")
       ) ;_ member
     ) ;_ not
      (princ (strcat "\nError: " msg))
   ) ;_ if
 ) ;_ defun


;;; Convert selection set to list of ename or vla objects
;;; #Selection - SSGET selection set
;;; #VLAList - T for vla objects, nil for ename
;;; Alan J. Thompson, 04.20.09
 (defun AT:SS->List (#Selection #VlaList / #List)
   (and #Selection
        (setq #List (vl-remove-if
                      'listp
                      (mapcar 'cadr (ssnamex #Selection))
                    ) ;_ vl-remove-if
        ) ;_ setq
        (if #VlaList
          (setq #List (mapcar 'vlax-ename->vla-object #List))
        ) ;_ if
   ) ;_ and
   #List
 ) ;_ defun


;;; Undo Begin/End (Either VLA or Command)
;;; #CommandVLA - "V" for VLA OR "C" for Command
;;; #BeginEnd - "B" for Undo Begin OR "E" for Undo End
;;; Alan J. Thompson, 03.23.09
(defun AT:Undo (#CommandVLA #BeginEnd / #OldCmdecho)
 (if
   (and
     (member (strcase #CommandVLA) (list "C" "V"))
     (member (strcase #BeginEnd) (list "B" "E"))
   ) ;_ and
    (cond
      ;; COMMAND Undo Options
      ((eq "C" (strcase #CommandVLA))
       (setq #OldCmdecho (getvar "cmdecho"))
       (setvar "cmdecho" 0)
       (cond
         ;; Undo Begin
         ((eq "B" (strcase #BeginEnd)) (command "_.undo" "_begin"))
         ;; Undo End
         ((eq "E" (strcase #BeginEnd)) (command "_.undo" "_end"))
       ) ;_ cond
       (setvar "cmdecho" #OldCmdecho)
      )
      ;; VLA Undo Options
      ((eq "V" (strcase #CommandVLA))
       (cond
         ;; Undo Begin
         ((eq "B" (strcase #BeginEnd))
          (vla-StartUndoMark
            (vla-get-ActiveDocument
              (vlax-get-Acad-Object)
            ) ;_ vla-get-ActiveDocument
          ) ;_ vla-StartUndoMark
         )
         ;; Undo End
         ((eq "E" (strcase #BeginEnd))
          (vla-EndUndoMark
            (vla-get-ActiveDocument
              (vlax-get-Acad-Object)
            ) ;_ vla-get-ActiveDocument
          ) ;_ vla-EndUndoMark
         )
       ) ;_ cond
      )
    ) ;_ cond
 ) ;_ if
) ;_ defun


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;; MAIN ROUTINE ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

 (vl-load-com)

 (AT:Undo "V" "B")
 ;; background offset setting
 (setq #BackgroundOffset 1.0)

 (cond
   ;; select mtext and multileaders
   ((setq #SSList
           (AT:SS->List (ssget ":L" '((0 . "MTEXT,MULTILEADER"))) T)
    ) ;_ setq
    ;; something selected, time to process data
    (mapcar
      '(lambda (x)
         (cond
           ;; mtext
           ((eq (vla-get-ObjectName x) "AcDbMText")
            (if (eq (vla-get-backgroundfill x) :vlax-false)
              (progn
                ;; set backgroundfill to true
                (vla-put-backgroundfill x :vlax-true)
                ;; convert object to ename and entmod offset
                (setq #Ent (entget (vlax-vla-object->ename x)))
                (entmod (subst (cons 45 #BackgroundOffset)
                               (assoc 45 #Ent)
                               #Ent
                        ) ;_ subst
                ) ;_ entmod
              ) ;_ progn
              ;; set backgroundfill to false
              (vla-put-backgroundfill x :vlax-false)
            ) ;_ if
           )
           ;; multileader
           ((eq (vla-get-Objectname x) "AcDbMLeader")
            (if (eq (vla-get-TextBackgroundFill x) :vlax-false)
              (progn
                ;; set background fill to true
                (vla-put-TextBackgroundFill x :vlax-true)
                ;; convert object to ename and entmod offset
                (setq #Ent (entget (vlax-vla-object->ename x)))
                (entmod (subst (cons 141 #BackgroundOffset)
                               (assoc 141 #Ent)
                               #Ent
                        ) ;_ subst
                ) ;_ entmod
              ) ;_ progn
              ;; set backgroundfill to false
              (vla-put-TextBackgroundFill x :vlax-false)
            ) ;_ if
           )
         ) ;_ cond
       ) ;_ lambda
      #SSList
    ) ;_ mapcar
   )
 ) ;_ cond

 (AT:Undo "V" "E")

 (princ)
) ;_ defun

 

just for info... we have been dealing with multiline attributes in autocad 2008... it seems to be a known bug.. fixed in 2009... but I just want to let people here know about it...

 

http://discussion.autodesk.com/forums/thread.jspa?threadID=588667

 

http://discussion.autodesk.com/forums/message.jspa?messageID=5923690

Edited by gilsoto13
Link to comment
Share on other sites

  • 6 years later...

I know this topic is old but I'm wondering if 2016 has added a way to mask single line attributes. I know multiline works but it requires additional steps in editing that slows things down.

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