Results 1 to 4 of 4

Thread: Changing block attributes across several layers

  1. #1
    Member
    Join Date
    2018-03
    Posts
    12
    Login to Give a bone
    0

    Default Changing block attributes across several layers

    We normally have blocks generated in a third party software containing data for survey pick-up attributes. We have a suite of LISPs I've inherited that allow us to pull multileaders with different configurations of the attributes. When we use these lisps with our 'vanilla' data the LISPs draw the multileaders into a layer named [block insertion layer]_txt e.g. GAS_txt. We're getting some data from a subcontractor that's using civil 3d and they are creating blocks "DIAG-CROSS" that have attributes based on their original 'object data', (I can't read object data in our AutoCAD 201. They made the block and it's attributes in layer "0".

    I've altered our LISPs to change the attribute sets into what they're providing, it's different to our vanilla attributes, and everything works except the layer designation.

    I can edit the block and change the layer for the attributes from "0" to "0022" and the multileaders appear locked on the layer of the attribute and write to "0022_txt" instead of e.g. "GAS_txt", which they were doing in vanilla. I found a LISP called "UPAL" and it changes the layer for the attributes, they change to the defined colour of the new layer, but when using the multileader LISP it still references whatever the attribute text layer is set to in the block editor "0022". I've changed the properties of individual blocks using the enhanced attribute editor tool to [ Layer: "GAS" ] and the multileader still writes to "0022_txt".

    I can't see why:

    Code:
     (setq sel1 (ssget "x" '((0 . "INSERT")(2 . "DIAG-CROSS"))))
    in the automated LISPS, or :

    Code:
     (setq 1Att (entnext Blname))
     (setq 1AtEnt (entget 1Att))
     (while (/= (cdr (assoc 0 1AtEnt)) "SEQEND")
     (progn 
     (setq tag (cdr (assoc 2 1AtEnt)))
     (set (read tag) (cdr (assoc 1 1AtEnt)))
     (setq lay (cdr (assoc 8 1AtEnt)))
     (setq 1Att (entnext 1Att))
     (setq 1AtEnt (entget 1Att))
    )
    )
    )

    in the manual multileader lisps would do anything other than look up the dxf groups for the block inserted not the attributes of the block.

    Is there some way to globally change inserted block attribute's layers to the same layer as the inserted block? or maybe there's some inherent difference with the new block that's interfering with the LISPs?

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

    Default Re: Changing block attributes across several layers

    Quote Originally Posted by sorourke765462 View Post
    Is there some way to globally change inserted block attribute's layers to the same layer as the inserted block? or maybe there's some inherent difference with the new block that's interfering with the LISPs?
    Hi,
    This one?
    Code:
    (defun c:Test (/ int sel ent get lay)
      (and (setq int -1
                 sel (ssget "_X" '((0 . "INSERT") (2 . "DIAG-CROSS") (66 . 1)))
           )
           (while (setq ent (ssname sel (setq int (1+ int))))
             (setq lay (assoc 8 (entget ent)))
             (while
               (not (eq (cdr (assoc 0 (setq get (entget (setq ent (entnext ent)))))) "SEQEND"))
                (entmod (subst lay (assoc 8 get) get))
             )
           )
      )
      (princ)
    )

  3. #3
    Member
    Join Date
    2018-03
    Posts
    12
    Login to Give a bone
    0

    Default Re: Changing block attributes across several layers

    Fantastic thank you.

    Any chance of an explanation?

    I wasn't expecting the attributes to exist separately from the block itself and looking at that bit of code I can 'see' : go get all the blocks that have been "insert"ed with the name "DIAG-CROSS" : set the variable 'lay' to the dxf code group 8 for each instance : then somewhere after 'while'(?) it does the layer changing? This is the first time I've seen dxf group '66' [entities follow] used, is this the code group that shows their are other associated entities (attributes in this case) and associates them with the original block?

    TY again for the solution.

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

    Default Re: Changing block attributes across several layers

    You're welcome.

    You did explain the process quite well and the dxf code 66 indicates is that the block reference is attributed block and this group code is for this specific purpose when normal / regular references don't have this group code 66 and to confirm this, just dump the dxf codes of attributed and regular blocks.

    You can read THIS LINK for more info.

Similar Threads

  1. Changing attributes Z axis within block
    By bradley.palmer in forum AutoCAD General
    Replies: 0
    Last Post: 2015-02-03, 06:01 AM
  2. Replies: 2
    Last Post: 2012-06-06, 12:28 PM
  3. Replies: 21
    Last Post: 2007-03-20, 02:03 PM
  4. Changing all attributes with the same tag
    By todd.mackay in forum AutoCAD General
    Replies: 3
    Last Post: 2005-11-21, 04:26 PM
  5. Changing the order of attributes
    By kdayman in forum VBA/COM Interop
    Replies: 2
    Last Post: 2005-02-15, 11:46 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
  •