Results 1 to 7 of 7

Thread: Help with LISP routine to toggle attribute background mask

  1. #1
    Member
    Join Date
    2015-01
    Posts
    43
    Login to Give a bone
    0

    Default Help with LISP routine to toggle attribute background mask

    I want to write a routine to toggle the background mask for a multi-line attribute on and off based on whether the attribute has a value or is just an empty string. (The problem is that an empty string still has a background mask which covers up whatever it's on top of.)

    I can add a background mask with this code:
    (setq entlist (entget (car (nentsel "Select Attribute: "))))
    (setq entlist (append entlist (list (cons 90 3) (cons 63 256) (cons 45 1.15) (cons 441 0))))
    (entmod entlist)

    I figured I could then remove the background mask of a selected attribute by adding every element of its entget list to a new entget list except for the DXF 63, 45 & 441 dotted pairs and setting the DXF 90 dotted pair to 2. Even though this new list is identical to the entget list for an attribute without a background mask (I checked this using UltraCompare), the entmod fails.

    If anyone has any ideas I would really appreciate it.

  2. #2
    All AUGI, all the time
    Join Date
    2010-06
    Posts
    962
    Login to Give a bone
    0

    Default Re: Help with LISP routine to toggle attribute background mask

    Hi,

    You can use the DXF 90 with 0 to fill off the background mask otherwise 1 along with the desired color DXF 63 and here is a small description From the Help document:

    Code:
    Group Code:          Description:
    
    90                   Background fill setting:
                         0 = Background fill off
                         1 = Use background fill color
                         2 = Use drawing window color as background fill color
    Have not tried that before but hope this would help.

  3. #3
    Member
    Join Date
    2015-01
    Posts
    43
    Login to Give a bone
    0

    Default Re: Help with LISP routine to toggle attribute background mask

    Thanks for the help Tharwat but I think there is some undocumented behavior going on (or a bug). The entget list for attributes without a background mask returns a value of 2 for the 90 DXF code and a value of 3 when there is a background mask. I tried a value of 0 for the 90 DXF code anyway but it still didn't work. As a test to rule out errors in my code, I manually turned off the background mask for the attribute and set that entget list to a variable. Then I manually turned the background mask back on and used the saved entget list variable in the call to (entmod) and it still failed.

    I think I'm at a dead end here. I've heard that it's been years since there has been any development in LISP so I guess stuff like this is an occupational hazard.

  4. #4
    All AUGI, all the time
    Join Date
    2010-06
    Posts
    962
    Login to Give a bone
    0

    Default Re: Help with LISP routine to toggle attribute background mask

    Can you upload a sample drawing to take a close look?

  5. #5
    Certifiable AUGI Addict
    Join Date
    2001-03
    Location
    Tallahassee, FL USA
    Posts
    3,667
    Login to Give a bone
    0

    Default Re: Help with LISP routine to toggle attribute background mask

    Quote Originally Posted by deheylen690271 View Post
    Thanks for the help Tharwat but I think there is some undocumented behavior going on (or a bug). The entget list for attributes without a background mask returns a value of 2 for the 90 DXF code and a value of 3 when there is a background mask.
    Seems to be undocumented behavior. The DXF background codes are the same for MTEXT and in my drawings the entget list for MTEXT without a background mask returns a value of 2 for the 90 DXF code and a value of 3 when there is a background mask. I'd recommend modifying the object instead with visual lisp. Here's a link for toggling MTEXT background that should get you started.
    http://forums.augi.com/showthread.ph...=1#post1128420

  6. #6
    Member
    Join Date
    2015-01
    Posts
    43
    Login to Give a bone
    0

    Default Re: Help with LISP routine to toggle attribute background mask

    Thanks for the link Tom. The problem isn't adding the background mask though, I can do that. The problem is getting rid of it once it's been added. My until-I-figure-this-out hack/work-around is to delete the block and then reinsert it, adding a background mask only to attributes that have a value. It's painful but at least it works.

  7. #7
    Certifiable AUGI Addict
    Join Date
    2001-03
    Location
    Tallahassee, FL USA
    Posts
    3,667
    Login to Give a bone
    0

    Default Re: Help with LISP routine to toggle attribute background mask

    Quote Originally Posted by deheylen690271 View Post
    Thanks for the link Tom. The problem isn't adding the background mask though, I can do that. The problem is getting rid of it once it's been added. My until-I-figure-this-out hack/work-around is to delete the block and then reinsert it, adding a background mask only to attributes that have a value. It's painful but at least it works.
    While for MTEXT the code in that thread toggles the background mask On and Off. It also shrinks the mtext width to the width of the text and sets the color to the drawing background color.

    It just needs to be modified to select an attribute instead.

Similar Threads

  1. toggle a view port during a lisp routine
    By cjharley1450642179 in forum AutoLISP
    Replies: 11
    Last Post: 2014-04-23, 05:49 PM
  2. Set file name from block attribute with lisp routine
    By email.dnewton396831 in forum AutoLISP
    Replies: 0
    Last Post: 2013-07-03, 08:51 PM
  3. Attribute tags to have background mask
    By Wish List System in forum AutoCAD Wish List
    Replies: 0
    Last Post: 2012-09-05, 07:05 AM
  4. Toggle-Make-Background Mask and multi-selection
    By doggarn.70892 in forum AutoCAD Civil 3D - General
    Replies: 0
    Last Post: 2009-03-18, 02:29 PM
  5. Use LISP to turn off MTEXT background mask
    By jason.cyr13 in forum AutoLISP
    Replies: 2
    Last Post: 2007-08-03, 06:35 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •