Jump to content

Deleting Duplicate Attribute Tags


bustr

Recommended Posts

I see, So this is a two step program,

 

1. First to repair the old Tblock [with doubles] then migrate the data from OLD to NEW.

 

2. Retrieve the data from old / process the data / transfer it to the NEW.

 

When you run the lisp, the first of the duplicates value will remain and the duplicates will cease to exist.

 

So which one is it?

Link to comment
Share on other sites

  • Replies 30
  • Created
  • Last Reply

Top Posters In This Topic

  • bustr

    16

  • pBe

    9

  • Tharwat

    4

  • Lee Mac

    2

Top Posters In This Topic

Posted Images

I see, So this is a two step program,

 

1. First to repair the old Tblock [with doubles] then migrate the data from OLD to NEW.

 

2. Retrieve the data from old / process the data / transfer it to the NEW.

 

When you run the lisp, the first of the duplicates value will remain and the duplicates will cease to exist.

 

So which one is it?

 

 

Number one was my idea; Repair the block then redefine it. Number one seems to be above my level of skill. Number two is waaaay above my skill level.

 

To break it down:

-Eliminating the duplicates while keeping the first of the duplicates and it's value.

-Renaming the tags to match those in the new_border

-Renaming the old border with the name of the new

-Inserting the new_border from an external location to redefine the old one already in the drawing.

-Synchronizing the attributes of the border so that they all return to their proper locations, sizes etc.

Link to comment
Share on other sites

Number one was my idea; Repair the block then redefine it. Number one seems to be above my level of skill. Number two is waaaay above my skill level.

 

You want my advice? Take option 2. its easier its faster. but you're going to have to wait till tommorrow. (for me that is) :)

Link to comment
Share on other sites

You want my advice? Take option 2. its easier its faster. but you're going to have to wait till tommorrow. (for me that is) :)

 

No problem! Thanks for all of your help!:)

Link to comment
Share on other sites

Bustr,

 

(defun c:RepBlock ( / x _dup _insert a b h bname)
(vl-load-com)
(setq x (vla-get-ActiveDocument (vlax-get-acad-object)))      
(defun _dup (d / y z)
                (while (setq y (car d))
                      (setq z (cons y z)
                            d (vl-remove y (cdr d))))  z)
(defun _insert (pt bn dc)
      (vlax-invoke (vlax-get (vla-get-ActiveLayout dc)
                    'Block) 'InsertBlock pt bn 1 1 1 0))
(setq bname (if (not (tblsearch "Block" [color=darkgreen]"LOOP11X17"[/color]))
                               "C:\\mike\\autocad\\RenAttrib\\[color=darkgreen]LOOP11X17[/color].dwg" [color=darkgreen]"LOOP11X17"[/color]))      
(vlax-for block (vla-get-modelspace x)
 (if  (and
 (eq (vla-get-objectname block)  "AcDbBlockReference")
 (eq (strcase (vla-get-effectivename block)) [color=darkgreen]"ILMST"[/color]))
              (progn
                     (setq a (_dup (mapcar '(lambda (j)
                              (list (vla-get-tagstring j)
                                    (vla-get-textstring j)))
                     (vlax-invoke block 'GetAttributes))))
  (foreach tg [color=darkgreen](reverse a)
[/color]   (if (setq f    (assoc (car tg)
                                             '(("04-16-90" "START_DATE")
                                               ("04-17-90" "CHKD_DATE")
                                               ("04-18-90" "APPD_DATE")
                                               ("F.T.D." "DRAWN_BY")
                                               ("C.B." "CHKD_BY")
                                               ("APP" "APPD_BY")
                                               ("DES-0" "DESC-0")
                                               ("DES-1" "DESC-1")
                                               ("DES-2" "DESC-2")
                                               ("DES-3" "DESC-3")
                                               ("DES-4" "DESC-4")
                                               ("SHEET" "SHEET#")
                                               [color=darkgreen]("AREA" "UNIT")
     ("SECTION" "AREA")
[/color]                                                )))
  (setq a (subst (list (cadr f) (cadr tg)) tg a))))
                       (setq b (_insert (vlax-get block 'Insertionpoint) bname x))
                       (vla-delete block)
                       (foreach ntg (mapcar '(lambda (j)
                              (list (vla-get-tagstring j) j))
                     (vlax-invoke b 'GetAttributes))
                             (if (setq h (assoc (car ntg) a))
                                 (vla-put-textstring (cadr ntg) (cadr h))))
                     )
                    )
             )(repeat 4
           (vla-purgeall x)
           )
     (princ)
)

 

1. This list shows Tag names to rename

("04-16-90" "START_DATE")("04-17-90" "CHKD_DATE")("04-18-90" "APPD_DATE")

("F.T.D." "DRAWN_BY")("C.B." "CHKD_BY")("APP" "APPD_BY")("DES-0" "DESC-0")

("DES-1" "DESC-1")("DES-2" "DESC-2")("DES-3" "DESC-3")("DES-4" "DESC-4")("SHEET" "SHEET#")

 

2. There are 23 Identical Tag names between OLD and NEW

 

3. Not included on this list are:

 

"S.F." "SECTION" ----> from "OLD_BORDER" , "MOC" "UNIT" on NEW_BORDER

 

"APP-0" "APP-1" "APP-2" "APP-3" "APP-4" ;

 

Not sure if S.F. is MOC , SECTION is UNIT, you tell me bustr

 

This is by all means not YET FINAL. I wrote it in such a way that you can either use a script or ODBX (ObjectDBX Wrapper by LeeMac) or even on a single opened drawing

 

NOTE: The reason why the previous codes posted "FAILED" is because with the way your title block is now . Deleting the first item of the duplicates is not a guarantee it holds the current and valid value. so it really means the code does exactly as its supposed to do.

 

EDIT: make sure you have a titleblock named OLD_BORDER not OLD_BORDER2 or anything else, otherwise we need to write a rename routine or use wcmatch for block name.

 

HTH

Edited by pBe
Add more items on list
Link to comment
Share on other sites

Just tried it. Awesome!

 

The old_border's real name is ILMST. The new_border's real name is LOOP11X17.

 

Could I just open the lisp in notepad do a find and replace text?

Link to comment
Share on other sites

Just tried it. Awesome!

 

The old_border's real name is ILMST. The new_border's real name is LOOP11X17.

 

Could I just open the lisp in notepad do a find and replace text?

 

Alrighty then. I updated the code for you. added "AREA" to UNIT" and "SECTION" to "AREA"

 

Why of course you can update the code with notepad. but i would suggest you start using VLIDE. with Ctrl+H you can also do Find/Replace and much more.

But while im here, i took the liberty in changing the block names for you.

 

Cheers and have fun with the code. :)

Link to comment
Share on other sites

This is really gonna make my job a lot easier. Thanks again for all of your help!

 

Great. Now you'll have more time for fun stuff :)

 

Cheers

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...