<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Change Attribute Tags by their Position instead of the Name in AutoCAD Forum</title>
    <link>https://forums.autodesk.com/t5/autocad-forum/change-attribute-tags-by-their-position-instead-of-the-name/m-p/8799853#M139190</link>
    <description>&lt;P&gt;@Anonymous&amp;nbsp; hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;if you don't give us the exact info on what we are facing and what it's extents we can't help you. attributes tags can be replaced by two methods:&lt;/P&gt;
&lt;P&gt;a) you supply the oldTag and the newTag&lt;/P&gt;
&lt;P&gt;b) scan the attribute by their order (as they appears in the block definition) and change them but still for each block attributes you have to supply the newTags (or set something base on a serial number) but relaying&amp;nbsp; on the attribute order is not 100% safe.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;post your most complicated drawing so i can take a look and a list of block names and attributes.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Moshe&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Sat, 18 May 2019 18:31:19 GMT</pubDate>
    <dc:creator>Moshe-A</dc:creator>
    <dc:date>2019-05-18T18:31:19Z</dc:date>
    <item>
      <title>Change Attribute Tags by their Position instead of the Name</title>
      <link>https://forums.autodesk.com/t5/autocad-forum/change-attribute-tags-by-their-position-instead-of-the-name/m-p/8797146#M139185</link>
      <description>&lt;P&gt;Hello, we got alot drawings that we convert from microstation to .DWG and now we have to replace every Attribute-Tag with our own Names - we got a Script, dont really know from where but its pretty straight forward.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;;;; Rename attributes
(defun RenAttrib ($blk $old $new / blocks bo eo ao)
  ;; Get blocks collection in current drawing
  (setq blocks (vla-get-Blocks (vla-get-ActiveDocument (vlax-get-acad-object))))
  ;; Step through all blocks
  (vlax-for bo blocks
    ;; Step through all entities inside block
    (vlax-for eo bo
      (cond
        ;; If attdef &amp;amp; in target block &amp;amp; old tag
        ((and (= (vla-get-ObjectName eo) "AcDbAttributeDefinition")
              (= (strcase (vla-get-Name bo)) (strcase $blk))
              (= (vla-get-TagString eo) $old)
         ) ;_ end of and
         (vla-put-TagString eo $new) ;Change to new name
        )
        
        ;; If block reference &amp;amp; target block
        ((and (= (vla-get-ObjectName eo) "AcDbBlockReference")
              (= (strcase (vla-get-EffectiveName eo)) (strcase $blk))
         ) ;_ end of and
         ;; Step through all attributes
         (foreach ao (vlax-safearray-&amp;gt;list (vlax-variant-value (vla-GetAttributes eo)))
           ;; Check if target attrib
           (if (= (strcase (vla-get-TagString ao)) (strcase $old))
             (vla-put-TagString ao $new) ;Change to new name
           ) ;_ end of if
         ) ;_ end of foreach
        )
      ) ;_ end of cond
    ) ;_ end of vlax-for
  ) ;_ end of vlax-for
) ;_ end of defun&lt;/PRE&gt;
&lt;P&gt;and we run it with the command&lt;/P&gt;
&lt;PRE&gt;(RenAttrib "TESTBLK" "OLDTAG" "NEWTAG")&lt;/PRE&gt;
&lt;P&gt;lets jump right at the problem-&lt;/P&gt;
&lt;P&gt;The "OLDTAG" does change for the same blocks after every new convert from microstatio.&lt;/P&gt;
&lt;P&gt;For example.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;First DWG&lt;/P&gt;
&lt;P&gt;Blockname: KI1&lt;/P&gt;
&lt;P&gt;Tagname: KI1_1&lt;/P&gt;
&lt;P&gt;Tagname2: KI1_2&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Second DWG&lt;/P&gt;
&lt;P&gt;Blockname: KI1&lt;/P&gt;
&lt;P&gt;Tagname: KI1_3&lt;/P&gt;
&lt;P&gt;Tagname2: KI1_4&lt;/P&gt;
&lt;P&gt;-----------------------------------------&lt;/P&gt;
&lt;P&gt;Even tho its the same block the Attribute Tags seem to count up and we cant use a Excel for the Tag names to maximise efficency with the .lsp&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;My Question:&lt;/P&gt;
&lt;P&gt;Is it possible to set the reference of the Script to the position of the AttributeTag instead of the old name?&lt;/P&gt;
&lt;P&gt;E.g.&lt;/P&gt;
&lt;PRE&gt;(RenAttrib "BLOCKNAME" "FIRST NEW TAG" "SECOND NEW TAG")&lt;/PRE&gt;
&lt;P&gt;Would be awesome if someone could tell me if its possible or how to do it. Or even "just" change the existing script.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;P.S. if someone knows where the original script came from please post source below for credit.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Best regards!&lt;/P&gt;</description>
      <pubDate>Fri, 17 May 2019 05:22:37 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/autocad-forum/change-attribute-tags-by-their-position-instead-of-the-name/m-p/8797146#M139185</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2019-05-17T05:22:37Z</dc:date>
    </item>
    <item>
      <title>Re: Change Attribute Tags by their Position instead of the Name</title>
      <link>https://forums.autodesk.com/t5/autocad-forum/change-attribute-tags-by-their-position-instead-of-the-name/m-p/8797257#M139186</link>
      <description>&lt;P&gt;Would you post some dwg with a block to illustrate the issue? Original block and desired outcome?&lt;/P&gt;
&lt;P&gt;Not sure what you mean by 1st &lt;EM&gt;new&lt;/EM&gt; tag, 2nd...&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Anyway, it looks like the original code was posted by its author&amp;nbsp;&lt;A href="https://forums.augi.com/showthread.php?100153-Renaming-Attribute-Tags&amp;amp;p=968279&amp;amp;viewfull=1#post968279" target="_blank" rel="noopener"&gt;HERE&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 17 May 2019 07:17:34 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/autocad-forum/change-attribute-tags-by-their-position-instead-of-the-name/m-p/8797257#M139186</guid>
      <dc:creator>ВeekeeCZ</dc:creator>
      <dc:date>2019-05-17T07:17:34Z</dc:date>
    </item>
    <item>
      <title>Re: Change Attribute Tags by their Position instead of the Name</title>
      <link>https://forums.autodesk.com/t5/autocad-forum/change-attribute-tags-by-their-position-instead-of-the-name/m-p/8799659#M139187</link>
      <description>Can't post the dwg, wouldn't anything anyways. I can try to explain it in&lt;BR /&gt;more detail.&lt;BR /&gt;&lt;BR /&gt;At first we got the drawing in Microstation let's name it "a" after we&lt;BR /&gt;convert it its a.dwg and the block name is "block-a" with 2 different&lt;BR /&gt;attribute attached called "block-a-attribute1" and "block-a-attribute2".&lt;BR /&gt;&lt;BR /&gt;So far so good.&lt;BR /&gt;&lt;BR /&gt;Let's convert the drawing "a" another time from Microstation to Autocad -&lt;BR /&gt;this time the block name is still "block-a" but the attribute name of the&lt;BR /&gt;same block in the same .dwg as above is now "block-a-attribute3" and&lt;BR /&gt;"block-a-attribute4".&lt;BR /&gt;&lt;BR /&gt;Let me try to bring it in one sentence.&lt;BR /&gt;&lt;BR /&gt;TL:DR - Block names for the same block doesn't change on the convertion but&lt;BR /&gt;every new convertion does count up the number behind attribute Names.&lt;BR /&gt;&lt;BR /&gt;Script should target the position of the attribute name instead of the name&lt;BR /&gt;itself.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Im on mobile sorry for not editing and probably hard to understand use of&lt;BR /&gt;the English language.&lt;BR /&gt;Gonna add the credits on the original script as soon as I'm on desktop.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Best regards&lt;BR /&gt;</description>
      <pubDate>Sat, 18 May 2019 13:02:27 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/autocad-forum/change-attribute-tags-by-their-position-instead-of-the-name/m-p/8799659#M139187</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2019-05-18T13:02:27Z</dc:date>
    </item>
    <item>
      <title>Re: Change Attribute Tags by their Position instead of the Name</title>
      <link>https://forums.autodesk.com/t5/autocad-forum/change-attribute-tags-by-their-position-instead-of-the-name/m-p/8799726#M139188</link>
      <description>&lt;P&gt;@Anonymous&amp;nbsp; hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;1. the lisp function you post looks good although i can not test it (cause you did not post a dwg) but it has a 'little' drawback...for each block it scan the whole database time and time again so i correct it to be effective (hope you do not (or the &lt;SPAN&gt;author)&lt;/SPAN&gt;&amp;nbsp;mind&amp;nbsp;&lt;img id="smileylol" class="emoticon emoticon-smileylol" src="https://forums.autodesk.com/i/smilies/16x16_smiley-lol.png" alt="Smiley LOL" title="Smiley LOL" /&gt;)&lt;/P&gt;
&lt;P&gt;2. in order to base the program on attribute coordinates you have to provide those coordinates to the function and i assume you do not have that beyond that you could not be sure that attributes are not moved from one convert to another. so this still must be base on tag names.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;3. attached my version to solved this called RAT (rename attributes) and it starts by defining a list of blocks and attributes name all strings. you need to populate this list with your blocks name and the attributes old tag and the new tag to be replaced. make sure not to &lt;SPAN&gt;spoil&lt;/SPAN&gt; the format, each sub list starts with the block name and continue with repeating old tag and new tag. each name (string) start and ends with&amp;nbsp;&lt;SPAN&gt;double quotes so make sure not to miss that.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;by the way do you know in advance what will be the old tags or you have to open each converted drawing and find them?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;enjoy&lt;/P&gt;
&lt;P&gt;Moshe&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;(setq data^ '( ("Block1" ("oldTag1" "newTag1")
	                 ("oldTag2" "newTag2")
	                 ("oldTag3" "newTag3")
	       ); list
               ("Block2" ("oldTag1" "newTag1")
	                 ("oldTag2" "newTag2")
	                 ("oldTag3" "newTag3")
	       ); list
             ); list
       
 ); setq&lt;/PRE&gt;
&lt;P&gt;and here is the whole program.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;(defun C:RAT (/ RenAttrib ; local function
	        data^)

 ;;; Rename attributes
 (defun RenAttrib ($blk $old $new / blocks bo eo ao)
  ;; Get blocks collection in current drawing
  (setq blocks (vla-get-Blocks (vla-get-ActiveDocument (vlax-get-acad-object))))
  ;; Step through all blocks
  (if (setq bo (vla-item blocks $blk))
   ;; Step through all entities inside block
   (vlax-for eo bo
    (cond
     ;; If attdef &amp;amp; in target block &amp;amp; old tag
     ((and (= (vla-get-ObjectName eo) "AcDbAttributeDefinition")
           (= (strcase (vla-get-Name bo)) (strcase $blk))
           (= (vla-get-TagString eo) $old)
      ) ;_ end of and
      (vla-put-TagString eo $new) ;Change to new name
     )
        
     ;; If block reference &amp;amp; target block
     ((and (= (vla-get-ObjectName eo) "AcDbBlockReference")
           (= (strcase (vla-get-EffectiveName eo)) (strcase $blk))
      ) ;_ end of and
      ;; Step through all attributes
      (foreach ao (vlax-safearray-&amp;gt;list (vlax-variant-value (vla-GetAttributes eo)))
       ;; Check if target attrib
       (if (= (strcase (vla-get-TagString ao)) (strcase $old))
        (vla-put-TagString ao $new) ;Change to new name
       ) ;_ end of if
      ) ;_ end of foreach
     )
    ) ;_ end of cond
   ) ;_ end of vlax-for
  ); if  
 );_ end of defun

  
 ; here start C:RAT  
 (setq data^ '( ("Block1" ("oldTag1" "newTag1")
	                  ("oldTag2" "newTag2")
	                  ("oldTag3" "newTag3")
	        ); list
                ("Block2" ("oldTag1" "newTag1")
	                  ("oldTag2" "newTag2")
	                  ("oldTag3" "newTag3")
	        ); list
              ); list
       
 ); setq

 (foreach blk data^
  (foreach item blk
   (RenAttrib blk (car item) (cadr item))
  ); foreach
 ); foreach

 (princ) 
); C:RAT

&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 18 May 2019 15:13:06 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/autocad-forum/change-attribute-tags-by-their-position-instead-of-the-name/m-p/8799726#M139188</guid>
      <dc:creator>Moshe-A</dc:creator>
      <dc:date>2019-05-18T15:13:06Z</dc:date>
    </item>
    <item>
      <title>Re: Change Attribute Tags by their Position instead of the Name</title>
      <link>https://forums.autodesk.com/t5/autocad-forum/change-attribute-tags-by-their-position-instead-of-the-name/m-p/8799783#M139189</link>
      <description>&lt;P&gt;First of all - Thanks for your work.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Second - doesn't really solve my problem. The range of the AttributeNames (Tags) are very wide something between one and 50.000 - so anything that needs the old name to replace the current one is pretty useless. I could make an excel sheet with 50.000 variations of every Attribute name just with a diffrent number behind it but we're talking about around 150 diffrent blocks and i think with such big data it will just crash. (7.5Mil different attributenames).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Don't really get the coordinate part. Another try to explain it with my broken English-&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="autocad-tips-attributes-battman-1.png" style="width: 474px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/637981i7F508609661005B5/image-size/large?v=v2&amp;amp;px=999" role="button" title="autocad-tips-attributes-battman-1.png" alt="autocad-tips-attributes-battman-1.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;This opens up with the BATTMAN function and the Tags "NO" and "DATE" are always in this exect order.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Goal is to target the order direct with the script - say -&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;(setq data^ '( ("Block1" ("Tag_Order_Position1" "newTag1")
	       ); list
               ("Block2" ("Tag_Order_Position2" "newTag1")
       
 ); setq&lt;/PRE&gt;
&lt;P&gt;Maybe its just not possible to make it this way :x&lt;/P&gt;
&lt;P&gt;I also don't have acces to AutoCAD right now to test anything tho..&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Still thank you very much for your effort I appreciate!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;( A script that changes every attribute name globaly to "XY" would also work tho - atleast i can name them without open every BATTMAN on the block to write them down)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Best regards&lt;/P&gt;</description>
      <pubDate>Sat, 18 May 2019 16:59:09 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/autocad-forum/change-attribute-tags-by-their-position-instead-of-the-name/m-p/8799783#M139189</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2019-05-18T16:59:09Z</dc:date>
    </item>
    <item>
      <title>Re: Change Attribute Tags by their Position instead of the Name</title>
      <link>https://forums.autodesk.com/t5/autocad-forum/change-attribute-tags-by-their-position-instead-of-the-name/m-p/8799853#M139190</link>
      <description>&lt;P&gt;@Anonymous&amp;nbsp; hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;if you don't give us the exact info on what we are facing and what it's extents we can't help you. attributes tags can be replaced by two methods:&lt;/P&gt;
&lt;P&gt;a) you supply the oldTag and the newTag&lt;/P&gt;
&lt;P&gt;b) scan the attribute by their order (as they appears in the block definition) and change them but still for each block attributes you have to supply the newTags (or set something base on a serial number) but relaying&amp;nbsp; on the attribute order is not 100% safe.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;post your most complicated drawing so i can take a look and a list of block names and attributes.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Moshe&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 18 May 2019 18:31:19 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/autocad-forum/change-attribute-tags-by-their-position-instead-of-the-name/m-p/8799853#M139190</guid>
      <dc:creator>Moshe-A</dc:creator>
      <dc:date>2019-05-18T18:31:19Z</dc:date>
    </item>
    <item>
      <title>Re: Change Attribute Tags by their Position instead of the Name</title>
      <link>https://forums.autodesk.com/t5/autocad-forum/change-attribute-tags-by-their-position-instead-of-the-name/m-p/8801695#M139191</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/52747"&gt;@Moshe-A&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;b) scan the attribute by their order (as they appears in the block definition) and change them but still for each block attributes you have to supply the newTags (or set something base on a serial number) but relaying&amp;nbsp; on the attribute order is not 100% safe.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Sounds exactly what i need. Cant post a .dwg cuz&lt;/P&gt;
&lt;PRE id="tw-target-text" class="tw-data-text tw-ta tw-text-medium" style="text-align: left; height: 72px;" data-placeholder="Übersetzung" data-fulltext=""&gt;&lt;SPAN&gt;Confidentiality Agreement&lt;/SPAN&gt;&lt;/PRE&gt;
&lt;P&gt;Best regards &lt;/P&gt;</description>
      <pubDate>Mon, 20 May 2019 11:16:33 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/autocad-forum/change-attribute-tags-by-their-position-instead-of-the-name/m-p/8801695#M139191</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2019-05-20T11:16:33Z</dc:date>
    </item>
  </channel>
</rss>

