Page 2 of 2 FirstFirst 12
Results 11 to 15 of 15

Thread: Setq the value of a given Attribute tag from a Block

  1. #11
    Active Member mweaver's Avatar
    Join Date
    2015-12
    Location
    Utah
    Posts
    69
    Login to Give a bone
    0

    Default Re: Setq the value of a given Attribute tag from a Block

    Try this get the attributes and values from your insertion(s):

    Code:
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    ;;;  Gather Attributes and values        ;;;
    ;;;  Function:  gatheratts         ;;;
    ;;;  Purpose: Gathers all the attributes and their values into a list    ;;;
    ;;;    for all insertions of specified blocks.     ;;;
    ;;;  Arguments: bnames  list of block names to find     ;;;
    ;;;  Returns: A list of lists Organized by block name as follows:    ;;;
    ;;;    (          ;;;
    ;;;      (bname1  the name of the first block    ;;;
    ;;;        (bref1 atts) the bref object followed by a list of attrib objects ;;;
    ;;;        (bref2 atts) the bref object followed by a list of attrib objects ;;;
    ;;;      )          ;;;
    ;;;      (bname2  the name of the second block    ;;;
    ;;;        (bref3 atts) the bref object followed by a list of attrib objects ;;;
    ;;;        (bref4 atts) the bref object followed by a list of attrib objects ;;;
    ;;;      )          ;;;
    ;;;    )          ;;;
    ;;;  Dependencies: none         ;;;
    ;;;  In the above, atts is list of dotted pairs, car being the tagstring, and cdr ;;;
    ;;;    being the attribute object.  Thus, the attribute object for any attribute can ;;;
    ;;;    be extracted by:        ;;;
    ;;;   (cdr (assoc tag (cdr(nth indx(cdr (assoc bname rtlist))))))  ;;;
    ;;;   where:         ;;;
    ;;;    tag  = the attribute tag string    ;;;
    ;;;    indx = is the nth insertion of bname    ;;;
    ;;;    bname = the block name     ;;;
    ;;;    rtlist = the list returned by gatheratts   ;;;
    ;;;  There may be any number of block names (bname) and any number of block  ;;;
    ;;;    insertions.         ;;;
    ;;;---------------------------------------------------------------------------------------------;;;
    ;;;  Example: Given a block named "BRD_TTL", Calling GatherAtts thus,    ;;;
    ;;;    (GatherAtts '("BRD_TTL")) will return the following:    ;;;
    ;;;(("BRD_TTL"           ;;;
    ;;;   (#<VLA-OBJECT IAcadBlockReference2 14d22114>      ;;;
    ;;;     ("BUILDING_NO"   . #<VLA-OBJECT IAcadAttributeReference2 14d21f04> ) ;;;
    ;;;     ("BLDG_NAME"    . #<VLA-OBJECT IAcadAttributeReference2 14d21eb4> ) ;;;
    ;;;     ("PACKAGE_NO"    . #<VLA-OBJECT IAcadAttributeReference2 14d21e64> ) ;;;
    ;;;     ("DRAWING_TITLE"   . #<VLA-OBJECT IAcadAttributeReference2 14d21e14> ) ;;;
    ;;;     ("DRAWING_NO"    . #<VLA-OBJECT IAcadAttributeReference2 14d21dc4> ) ;;;
    ;;;     ("DRAWING_TITLE_LINE_1"  . #<VLA-OBJECT IAcadAttributeReference2 14d21d74> ) ;;;
    ;;;     ("DRAWING_TITLE_LINE_2"  . #<VLA-OBJECT IAcadAttributeReference2 14d21d14> ) ;;;
    ;;;     ("DRAWING_TITLE_LINE_3"  . #<VLA-OBJECT IAcadAttributeReference2 14d21cb4> ) ;;;
    ;;;     ("DRAWING_TITLE_LINE_4"  . #<VLA-OBJECT IAcadAttributeReference2 14d21c54> ) ;;;
    ;;;     ("CADD_NAME"    . #<VLA-OBJECT IAcadAttributeReference2 14d21bf4> ) ;;;
    ;;;     ("SCALE"    . #<VLA-OBJECT IAcadAttributeReference2 14d21b94> ) ;;;
    ;;;     ("PROJECT_NO"    . #<VLA-OBJECT IAcadAttributeReference2 14d21814> ) ;;;
    ;;;     ("PROJECT_COORDINATOR"   . #<VLA-OBJECT IAcadAttributeReference2 14d217b4> ) ;;;
    ;;;     ("ENGINEERING_COORDINATOR"  . #<VLA-OBJECT IAcadAttributeReference2 14d21754> ) ;;;
    ;;;     ("L1REV"    . #<VLA-OBJECT IAcadAttributeReference2 14d216f4> ) ;;;
    ;;;     ("L1DATE"    . #<VLA-OBJECT IAcadAttributeReference2 14d21694> ) ;;;
    ;;;     ("L1DESC"    . #<VLA-OBJECT IAcadAttributeReference2 14d21634> ) ;;;
    ;;;     ("L1BY"    . #<VLA-OBJECT IAcadAttributeReference2 14d215d4> ) ;;;
    ;;;     ("L2REV"    . #<VLA-OBJECT IAcadAttributeReference2 14d21574> ) ;;;
    ;;;     ("L2DATE"    . #<VLA-OBJECT IAcadAttributeReference2 14d21514> ) ;;;
    ;;;     ("L2DESC"    . #<VLA-OBJECT IAcadAttributeReference2 14d214b4> ) ;;;
    ;;;     ("L2BY"    . #<VLA-OBJECT IAcadAttributeReference2 14d21454> ) ;;;
    ;;;     ("L3REV"    . #<VLA-OBJECT IAcadAttributeReference2 14d213f4> ) ;;;
    ;;;     ("L3DATE"    . #<VLA-OBJECT IAcadAttributeReference2 14d21394> ) ;;;
    ;;;     ("L3DESC"    . #<VLA-OBJECT IAcadAttributeReference2 14d21334> ) ;;;
    ;;;     ("L3BY"    . #<VLA-OBJECT IAcadAttributeReference2 14d212d4> ) ;;;
    ;;;     ("ISSUE_STATUS"   . #<VLA-OBJECT IAcadAttributeReference2 14d26454> ) ;;;
    ;;;     ("ISSUE_STATUS1"   . #<VLA-OBJECT IAcadAttributeReference2 14d263f4> ) ;;;
    ;;;     ("ISSUE_STATUS2"   . #<VLA-OBJECT IAcadAttributeReference2 14d26394> ) ;;;
    ;;;   )            ;;;
    ;;; )            ;;;
    ;;;)            ;;;
    ;;;  If this were asssigned to variable "ATTS" then the attribute for a specific tag, say "L1BY";;;
    ;;;    would be retrieved with:         ;;;
    ;;; (cdr (assoc "L1BY" (cdr(nth 0 (cdr (assoc "BRD_TTL" ATTS))))))    ;;;
    ;;;    Assigning the result of this to ATT would let us retrieve the attribute value with: ;;;
    ;;;     (vla-get-textstring ATT)        ;;;
    ;;; and set the attribute value with:       ;;;
    ;;; (vla-put-textstring ATT "New")        ;;;
    ;;;  Note that if there were multiple insertions of this same block then we would get the ;;;
    ;;;    "L1BY" attribute from second insertion with:      ;;;
    ;;; (cdr (assoc "L1BY" (cdr(nth 1 (cdr (assoc "BRD_TTL" ATTS))))))    ;;;
    ;;;    Notice the 1 here            ^        ;;;
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

  2. #12
    Member
    Join Date
    2008-08
    Posts
    38
    Login to Give a bone
    0

    Talking Re: Setq the value of a given Attribute tag from a Block

    irneb

    You're a champion! It worked b-e-a-utifully when I tried it on my test drawing and I've now been able to create a new "trimmed down" script file to change any or all of the attributes in the titleblock in 1 run instead of 50 or more.

    Once again the members of AUGI have come to the fore and I thank you for your assistance.

    Robert Smeallie
    Electrical Design Engineer (and relieved draftsman)

  3. #13
    Certifiable AUGI Addict irneb's Avatar
    Join Date
    2015-11
    Location
    Jo'burg SA
    Posts
    4,512
    Login to Give a bone
    0

    Default Re: Setq the value of a given Attribute tag from a Block

    You're welcome, glad I could help!
    Knowledge is proportional to experience, but wisdom is inversely proportional to ego!
    My little bit of "wisdom": Hind-sight is useless, unless used to improve the next forethought!

  4. #14
    Member
    Join Date
    2006-09
    Posts
    2
    Login to Give a bone
    0

    Default Re: Setq the value of a given Attribute tag from a Block

    irneb

    Thanks ALOT....almost 10 years later! Was searching all day for a way to edit attributes from the command line in a script file. (GATTE command didn't work because the Tag's used underscores in their names.) But I was able to use your LSP code which allowed me to edit the attributes in my script file.

    BTW...here is the format to edit a single attribute using irneb's code:

    (ChaAttM "YOURBLOCKNAME" '(("YOURTAGNAME" . "YOURVALUE")))

  5. #15
    I could stop if I wanted to aaronic_abacus's Avatar
    Join Date
    2006-04
    Posts
    378
    Login to Give a bone
    0

    Default Re: Setq the value of a given Attribute tag from a Block


    http://www.watsonlisp.com

    Artificial Intelligence for AutoCAD
    Find detail drawings by text and attribute content!
    6000 lines of code and and in development since 1997.

Page 2 of 2 FirstFirst 12

Similar Threads

  1. Using SETQ to assign a block to a variable
    By jpcadconsulting347236 in forum AutoLISP
    Replies: 8
    Last Post: 2014-02-11, 04:44 PM
  2. How to change dynamic block attribute default values based on block selected?
    By zeirz109180 in forum Dynamic Blocks - Technical
    Replies: 2
    Last Post: 2013-12-13, 02:20 PM
  3. Replies: 13
    Last Post: 2012-09-18, 07:51 PM
  4. Copy previous Block Attribute Value to next Block Attribute
    By CADfunk MC in forum VBA/COM Interop
    Replies: 8
    Last Post: 2009-02-27, 09:46 PM
  5. Block Attribute Manager Vs. Enhanced Attribute Editor
    By zoomharis in forum AutoCAD General
    Replies: 0
    Last Post: 2006-04-15, 11:53 AM

Posting Permissions

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