ATT TAG does not update in blockeditor

ATT TAG does not update in blockeditor

DGRL
Advisor Advisor
1,077 Views
8 Replies
Message 1 of 9

ATT TAG does not update in blockeditor

DGRL
Advisor
Advisor

Dear coders,

 

I use a nice routine to rename ATT Tags from old to new.
When i open the block in blockeditor is still see the old names of the ATT Tags,

 

Battman does not work
How can i update the block with the new ATT Tag names?

When double click on block i can see all the new ATT Tags // only not in blockeditor

 

Kind regards,

Don

 

If this was of any help please kudo and/or Accept as Solution
Kind Regards
0 Likes
Accepted solutions (1)
1,078 Views
8 Replies
Replies (8)
Message 2 of 9

_gile
Consultant
Consultant

Hi,

 

It looks like you're confusing block definition (that you open in the block editor) and block references (inserted entities in some space that you can double-click).

 

To rename tags, you have to rename the attribute definitions (AcDbAttributeDefinition) in the block definition (AcDbBlockTableRecord) by programmation or from the block editor.

Then, you have to run the ATTSYNC command to synchronize the attributes references (AcDbAttributereference) in the inserted block references (AcDbBlockReference).



Gilles Chanteau
Programmation AutoCAD LISP/.NET
GileCAD
GitHub

Message 3 of 9

DGRL
Advisor
Advisor

Hi @_gile

 

i did not read your answer correctly

Can you give me an example of how to do such coz for now i think i changed it on the wrong place

 

 

If this was of any help please kudo and/or Accept as Solution
Kind Regards
0 Likes
Message 4 of 9

cadffm
Consultant
Consultant

Not confused?

 

It sounds your Tool (i dont know what the toll do) only change the TAGs of Attributes (which hang on Blockreferences),

and do not edit the Block (TAG of Attributdefinitions (ATTDEF).

 

You need a better Tool or work with Battman.

 

THIS IS A DOUBLEPOST/THREAD - here also the second thread

https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/att-tag-does-not-update-in-blockedit...

 

 

 

Sebastian

0 Likes
Message 5 of 9

_gile
Consultant
Consultant

@DGRL wrote:

 

ATTSYNC will bring back the OLD names and i need the NEW names

 

 


This is because the tags haven't been renamed in the block definition.

 

The ATTSYNC command re-build the attribute references in the block references according to the settings of the attribute definitions in the block definition.

 

Try to rename tags without programming, first you rename Attribute definitions tags in the block editor (or with _REFEDIT command) and then you ATTSYNC the inserted references.

 

To do the same by programming, you have to iterate through the block definition entities looking for attribute definitions, edit them, and then synchronize inserted references by calling the ATTSYNC command (or edit/re-build the attribute references in all block references).



Gilles Chanteau
Programmation AutoCAD LISP/.NET
GileCAD
GitHub

0 Likes
Message 6 of 9

DGRL
Advisor
Advisor

Hi @_gile and @cadffm

You guys are quick responing LOL
I changed my reply coz i did not read it well

I indeed used the wrong lisp

here i have 1 that does the job correctly

 

(setq tagLst ; All tags must be upper case.
    (list
      ;     OLD TAG NEW TAG PROMPT VALUE
      (list "ISO_PIPESPEC" "c" " ") ; \U+00A0 = Unicode non-breaking space.
      ;(list "SHT_CALL_ON" "ITEM_$" "PROMPTSTRING2" "VALUE2")
    )
  )

  (setq doc (vla-get-activedocument (vlax-get-acad-object)))
  (vla-endundomark doc)
  (vla-startundomark doc)
  (vlax-for blk (vla-get-blocks doc)
    (if (= :vlax-false (vla-get-isxref blk))
      (vlax-for obj blk
        (cond
          ((= "AcDbBlockReference" (vla-get-objectname obj))
            (if (= :vlax-true (vla-get-hasattributes obj))
              (foreach att (vlax-invoke obj 'getattributes)
                (if (setq new (assoc (vla-get-tagstring att) tagLst))
                  (progn
                    (vla-put-tagstring att (cadr new))
                    ;(vla-put-textstring att (cadddr new))
                  )
                )
              )
            )

          )
          ((= "AcDbAttributeDefinition" (vla-get-objectname obj))
            (if (setq new (assoc (vla-get-tagstring obj) tagLst))
              (progn
                (vla-put-tagstring obj (cadr new))
                ;(vla-put-textstring obj (cadddr new))
                (vla-put-promptstring obj (caddr new))
              )
            )
          )
        )
      )
    )
  )
  (vla-endundomark doc)
  (princ)

 

If this was of any help please kudo and/or Accept as Solution
Kind Regards
0 Likes
Message 7 of 9

_gile
Consultant
Consultant

Please, attentively read the replies you get.

I said you in this topic to only rename the attribute definitions and it has been repeated here and elsewhere by @cadffm and I: you do not have to rename the tags in the attribute references (ATTSYNC will do the job for you).



Gilles Chanteau
Programmation AutoCAD LISP/.NET
GileCAD
GitHub

0 Likes
Message 8 of 9

_gile
Consultant
Consultant
Accepted solution

Try something like this (not tested)

 

(setq tagLst ; All tags must be upper case.
    (list
      ;     OLD TAG NEW TAG PROMPT VALUE
      (list "ISO_PIPESPEC" "c" " ") ; \U+00A0 = Unicode non-breaking space.
      ;(list "SHT_CALL_ON" "ITEM_$" "PROMPTSTRING2" "VALUE2")
    )
  )

  (setq doc (vla-get-activedocument (vlax-get-acad-object)))
  (vla-endundomark doc)
  (vla-startundomark doc)
  ;; iterate the block table
  (vlax-for blk (vla-get-blocks doc)
    (if (= :vlax-false (vla-get-isxref blk))
      (progn
        (vlax-for obj blk
          (if (and (= "AcDbAttributeDefinition" (vla-get-objectname obj))
                   (setq new (assoc (vla-get-tagstring obj) tagLst))
              )
            (progn
              ;; rename the tag and prompt of the ATTDEF
              (vla-put-tagstring obj (cadr new))
              (vla-put-promptstring obj (caddr new))
              (setq name (vla-get-Name blk))
            )
          )
        )
        ;; ATTSYNC the inserted references
        (if (= name (vla-get-Name blk))
          (command "_.ATTSYNC" "_Name" name)
        )
      )
    )
  ) 
  (vla-endundomark doc)
  (princ)


Gilles Chanteau
Programmation AutoCAD LISP/.NET
GileCAD
GitHub

0 Likes
Message 9 of 9

DGRL
Advisor
Advisor

Hi @_gile

Sorry for late reply.

The code you provided works perfect

Thanks for this 🙂

Kind regards,

 

If this was of any help please kudo and/or Accept as Solution
Kind Regards
0 Likes