Author Topic: Several Attribute Tags with the Same name, anyway to put a suffix  (Read 1188 times)

0 Members and 1 Guest are viewing this topic.

MSTG007

  • Gator
  • Posts: 2606
  • I can't remeber what I already asked! I need help!
I know its been answered here before, just cant seem to find it. I am dealing with a drawing with lots of attributed bocks. but in the blocks they have several that have the same tag name. Is there any way to add a suffix to them?
Civil3D 2020

nobody

  • Swamp Rat
  • Posts: 861
  • .net stuff
Re: Several Attribute Tags with the Same name, anyway to put a suffix
« Reply #1 on: November 05, 2020, 05:29:01 PM »
Battman command maybe?  If you mean a suffix on the tag and not the value


MSTG007

  • Gator
  • Posts: 2606
  • I can't remeber what I already asked! I need help!
Re: Several Attribute Tags with the Same name, anyway to put a suffix
« Reply #2 on: November 06, 2020, 08:08:31 AM »
I think I stumbled on to something here. Just tryin to make it work.

https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/help-lisp-to-change-mulitiple-attribute-tags-amp-prompts/td-p/7451724

Code: [Select]

(defun ReTagDup (bname Tag2Inc / bname Tag2Inc Blocks Found)
(vl-load-com)     
(setq TagLoop Tag2Inc)
(if (setq  Blocks (ssget "_X" (list '(0 . "INSERT")'(66 . 1)(cons 2 bname))))
            (progn
            (repeat (sslength blocks)
                 (setq Found
                     (vl-remove-if-not
                                '(lambda (x)
                                      (assoc (car x) Tag2Inc))
                                (mapcar (function
                               (lambda (at)
                                     (list (vla-get-tagstring at)
                                           at)
                                     ))
                         (vlax-invoke (vlax-ename->vla-object (setq e (ssname Blocks 0)))
                               'Getattributes)
                         )))
                 (foreach itm (vl-sort Found '(lambda (j k)
                                      (< (car j)(car k))))
                            (setq inc (assoc (Car itm) TagLoop))
                            (vla-put-tagstring (cadr itm) (strcat (car inc) (itoa (setq i (cadr inc)))))
                            (setq TagLoop (subst (list (car inc) (setq i (1+ i))) inc TagLoop))
                            )
                      (setq TagLoop Tag2Inc)
                      (ssdel e blocks)
                      )
(vlax-for att (vla-item  (vla-get-blocks
                   (vla-get-ActiveDocument (vlax-get-acad-object)))
             bname)
      (if (and (eq (vla-get-objectname att)
                   "AcDbAttributeDefinition")
               (setq ren (assoc (vla-get-tagstring att) Tag2Inc)))
            (progn
                  (vla-put-tagstring
                        att
                        (strcat (car ren)
                                (itoa (setq i (cadr ren)))))
                  (setq Tag2Inc
                             (subst (list (car ren)
                                          (setq i (1+ i)))
                                    ren
                                    Tag2Inc))))
      )
                (command "_attsync" "_Name" bname)
)(princ "\n0 Objects Selected")
            )
(princ)
      )

(ReTagDup "cogoblock" '("Type" 1))
Civil3D 2020

nobody

  • Swamp Rat
  • Posts: 861
  • .net stuff
Re: Several Attribute Tags with the Same name, anyway to put a suffix
« Reply #3 on: November 06, 2020, 02:26:26 PM »
I think one of these:

https://www.cadtutor.net/forum/topic/23977-change-attribute-tags-for-blocks-using-lisp/

Alternately you can copy the blocks with base point to a drawing... rename the attribute, then paste them back in maybe.  Not as ideal but if you need an immediate solution.