Jump to content
JJRyuKnight

Copying Attribute data from one tittle block to another

Recommended Posts

JJRyuKnight

Hi,

 

I have a bit of problem I am hoping to get some help with. I have recently made a tittle block (We call them drawing borders) and we started using it for a new client. Everything was golden until some of the other firms took it and made a different one and changed all the attribute tags.

 

Now I have almost 100 drawings with the old tag names that the data needs to be put into the new and I really don't want to do it manually.

 

For instance:

 

Drawing #: used to be tag "DRAWING_NO" and is now DRG# but the Value for both needs to be 31-22-H-12542

 

I have about 100 drawings and each drawing title block has ~60 attributes that I need the data from one title block to the other because I need to change all of ours to the new title block.

 

If anyone has any suggestions please let me know. I am unable to send out the CAD files for each as they belong to the client instead of us.

 

Thanks,

Jason

Share this post


Link to post
Share on other sites
dbroada

I thought there was a way to remap the attributes built in to ACADE, at least that is what I was assured during my training. It was some time ago and I didn't try the feature out so can't advise more.

 

If you can't find it and nobody else comes along you could ask in the LISP section (or ask a mod to move this thread there) if anybody has something suitable. It is likely that somebody may offer to write you a bespoke routine. If they do be as explicit as possible what you want. It makes life a lot easier if you all agree the solution before the work starts.

Share this post


Link to post
Share on other sites
Dadgad

I think that Lee Mac has got a solution for you, he usually has.

 

http://www.lee-mac.com/bfind.html

 

I've not used it, and if this one is not the right one, check some of his others.

I believe this is going to make you very happy though. :D

Thanks Lee! :beer:

Share this post


Link to post
Share on other sites
BIGAL

Two possible ways make a new title block outside the dwg with tag names matching old tag names but with same block name cut and paste into dwg and redefine block.

 

2nd is use a lisp to read all attributes out of one block and insert them into a new title block. this example works on title blocks in layouts you would need to duplicate the code for a read 1st block and replace 2nd block.

 

3rd like second above you can just get the attributes in saved order and update a new title block in saved attribute order then you do not need to know attribute tag names. let me know if you want this code.

 

; changes to issued for construction
: thanks to lee mac for original code
(vl-load-com)
; 1.  Get current date in mm/dd/yy format.
(defun ddmmyy (/ x today)
    (setvar "cmdecho" 0)
    (setq x (getvar "CDATE"))                 ; get current date
    (setq today ( rtos x 2 4))                    ; convert to a string
    (setq date (strcat (substr today 7 2) "."    (substr today 5 2) "." (substr today 3 2) ))
)

(setq oldtag1 "DRAWING_STATUS") ;attribute tag name
(setq newstr1 "ISSUED FOR CONSTRUCTION")
(setq oldtag2 "REV_NO")  ;attribute tag name
(setq newstr2 "0")
(setq ss1 (ssget "x"  '((0 . "INSERT") (2 . "DA1DRTXT"))))
(setq inc (sslength ss1))
(repeat inc      
(foreach att (vlax-invoke (vlax-ename->vla-object (ssname SS1 (setq inc (1- inc)) )) 'getattributes)
(if (= oldtag1 (strcase (vla-get-tagstring att)))
(vla-put-textstring att newstr1) 
) ; end if
(if (= oldtag2 (strcase (vla-get-tagstring att)))
(vla-put-textstring att newstr2) 
) ; end if
) ; end for
) ;end repeat
(setq oldtag1 "REV-NO")
(setq newstr1 "0")
(ddmmyy)
(setq oldtag2 "DATE")
(setq newstr2 date)
(setq oldtag3 "AMENDMENT")
(setq newstr3 "ISSUED FOR CONSTRUCTION")
(setq ss2 (ssget "x"  '((0 . "INSERT") (2 . "REVTABLE"))))
(setq inc (sslength ss2))
(repeat inc
(foreach att (vlax-invoke (vlax-ename->vla-object (ssname ss2 (setq inc (1- inc)))) 'getattributes)
(if (= oldtag1 (strcase (vla-get-tagstring att)))
(vla-put-textstring att newstr1) 
)
(if (= oldtag2 (strcase (vla-get-tagstring att)))
(vla-put-textstring att newstr2) 
)
(if (= oldtag3 (strcase (vla-get-tagstring att)))
(vla-put-textstring att newstr3) 
)
)
)
(setq ss1 nil)
; (setq ss2 nil)
(princ)

Share this post


Link to post
Share on other sites
JJRyuKnight

Thanks Guys.

 

From what I can tell this might be the right track but the issue is that I have a macro to replace the border "^C^C-insert;24x36;2,2;;;;blockreplace;\Y;battman;^C^Cerase;last;;^C^C"

 

where '24x36' is the name of the new border. This macro only works if the tags are the same name but the tittle block is a different name. Kind of limiting but its been working for us.

 

My issue with Lee's program is it changes the values, what I would like to do is change the tag names or map the value's from one tag name to the next.

 

Am I explaining this right?

 

Thanks for all your help.

Share this post


Link to post
Share on other sites
wishbonesr

Got one for you. It's one of my first lisps ever, and is veerry hard to understand.

I'm almost certain Lee has something that does this though. Will look around if he doesn't get to see this post.

 

It's sooo one of those things that's so badly written it just shouldn't enter the web at all - but here it goes anyway.

 

See attached TrueBlockReplace.lsp

Can be automated by script or menu (pure command line).

Expects an .MF file which is a map file.

 

This is embarassing. Read the supplied map file that I used on a titleblock change project that had 11 different titleblocks consolidating into one version. I think it may give some insight.

 

If not, then I'll give a shot at explaining it. Hopefully there's something else out there. ;)

 

Edit: Oh. And the block name can be the same as the original. Just specify the file name with dwg and make sure the dwg (block) is in a search path, or supply the full pathing with the file name. Lisp/CAD paths use double \\ or /

Ex. c:\\temp\\mynewblock.dwg

or

c:/temp/mynewblock.dwg

 

It will make more sense once you read the mf file and the lisp header.

TrueBlockReplace.zip

Share this post


Link to post
Share on other sites
BIGAL

Not sure about your lisp experience but basicly the code above by me changes a couple of attributes in a block you just need to duplicate it to read the original block and then update a second block. Its almost done in example I like to think you would have a go at coding yourself.

 

some more explanation not actual program note the lines with GET & others with PUT

(setq oldtag1 "DRAWING_STATUS") 
(setq oldtag2 "REV_NO")

(setq ss1 (ssget "x"  '((0 . "INSERT") (2 . "yourfirstblockname"))))
(setq inc (sslength ss1))
(repeat inc      
(foreach att (vlax-invoke (vlax-ename->vla-object (ssname SS1 (setq inc (1- inc)) )) 'getattributes)
(if (= oldtag1 (strcase (vla-get-tagstring att)))
(setq oldtag1val (vla-get-textstring att)) 
) ; end if
(if (= oldtag2 (strcase (vla-get-tagstring att)))
(setq oldtag2val (vla-get-textstring att)))
) ; end if
) ; end for
) ;end repeat



(setq newtag1 "DRAWING") 
(setq newtag2 "REVISION")

(setq ss1 (ssget "x"  '((0 . "INSERT") (2 . "yoursecondblockname"))))
(setq inc (sslength ss1))
(repeat inc      
(foreach att (vlax-invoke (vlax-ename->vla-object (ssname SS1 (setq inc (1- inc)) )) 'getattributes)
(if (= newtag1 (strcase (vla-get-tagstring att)))
(vla-put-textstring att oldtag1) 
) ; end if
(if (= oldtag2 (strcase (vla-put-tagstring att oldtag2)))
(vla-put-textstring att oldtag2val))
) ; end if
) ; end for
) ;end repeat

Share this post


Link to post
Share on other sites
Starcross

Hello everyone,

 

I work for the same company as JJRyuKnight and I have been asked take over this task. I don't have nearly enough lisp experience to understand what the code that has been posted does, let alone be able to modify it. Trial and error has yielded more error than anything else.

 

I can tell you what I have done so far, and maybe with a little more direction I could be able to complete the lisp routine.

 

I have a toolbar button programed to add the new_block into the same DWG file as the old_block.

I used the macro "^C^C-insert;New_Block;0,0;;;;(Transfer_text)^P"

Where Transfer_Text is defined in the toolbar MNL file.

 

Where I run into trouble is how to code the lisp routine to extract the attribute text from the old_Block and paste it into the new_block attribute.

 

The attribute name in Old_block is "PLANT", the destination in New_block is the attribute "PROJECT1".

 

I have a transfer table of the old attributes to the new attribute names. If I had a section of code that I could copy and make the appropriate name changes to, I could fill out all 60 tags to transfer to the new_block.

 

Any assistance in this matter is greatly appreciated,

 

Thank you.

Share this post


Link to post
Share on other sites
Dadgad
Hello everyone,

 

I work for the same company as JJRyuKnight and I have been asked take over this task. I don't have nearly enough lisp experience to understand what the code that has been posted does, let alone be able to modify it. Trial and error has yielded more error than anything else.

 

I can tell you what I have done so far, and maybe with a little more direction I could be able to complete the lisp routine.

 

I have a toolbar button programed to add the new_block into the same DWG file as the old_block.

I used the macro "^C^C-insert;New_Block;0,0;;;;(Transfer_text)^P"

Where Transfer_Text is defined in the toolbar MNL file.

 

Where I run into trouble is how to code the lisp routine to extract the attribute text from the old_Block and paste it into the new_block attribute.

 

The attribute name in Old_block is "PLANT", the destination in New_block is the attribute "PROJECT1".

 

I have a transfer table of the old attributes to the new attribute names. If I had a section of code that I could copy and make the appropriate name changes to, I could fill out all 60 tags to transfer to the new_block.

 

Any assistance in this matter is greatly appreciated,

 

Thank you.

 

 

You might want to consider this excellent lisp from Lee Mac's site.

http://www.lee-mac.com/copyblock.html

Thanks Lee! :beer:

Share this post


Link to post
Share on other sites
Starcross

You might want to consider this excellent lisp from Lee Mac's site.

http://www.lee-mac.com/copyblock.html

Thanks Lee!

 

Thanks for the reply.

 

I took a look at the link, but it appears that lisp routine will make an exact duplicate of the block with new naming. Which will not help, as I have a defined second block with all the new attributes. The two blocks don't even look the same, or have the attributes in the same order.

 

What I really need is to know how to target a specific attribute field in a block, and extract the text. Then open the new block and paste it in a specific attribute field.

 

So far my searches through the forum hasn't turned up the right string of code.

Am I even thinking about the process correctly?

Share this post


Link to post
Share on other sites
Starcross

I thought I would update this post, I took a look around Lee's website over the weekend.

I think I found a set of code that will do what I need it to.

However I am having trouble understanding what needs to be replaced to make it work for my example above.

 

http://www.lee-mac.com/attributefunctions.html

 

Get Attribute Value

Block Name = Old_block

Attribute to Get value from = PLANT

 

Set Attribute Value

Block Name = New_block

Attribute to Set value from = Project1

 

Is there anything I am missing to make this code work for me?

Such as some code to store the Attribute value after the Get Value code does its work?

 

As always any assistance is appreciated, Thank you.

Share this post


Link to post
Share on other sites
BIGAL

Go back and look at my posts they do exactly what you asked for

 

OLDTAG1 replace with newstr1

Share this post


Link to post
Share on other sites
TommieRommie
Two possible ways make a new title block outside the dwg with tag names matching old tag names but with same block name cut and paste into dwg and redefine block.

 

2nd is use a lisp to read all attributes out of one block and insert them into a new title block. this example works on title blocks in layouts you would need to duplicate the code for a read 1st block and replace 2nd block.

 

3rd like second above you can just get the attributes in saved order and update a new title block in saved attribute order then you do not need to know attribute tag names. let me know if you want this code.

 

Hello everybody,

 

Sorry for being a couple years late to this thread but the third option BIGAL suggested is exactly what would make my 2500 files such a breeze to update.

 

Let me explain; I'd like to copy the values of the first 51 tags of my old block to the first 51 tags of the new block. Both my block names and my tag names are different from one block to the other but if I just keep the order of the values as per the old block, they would land at the correct tag in the new block.

 

BIGAL, would the code you mentioned do such a thing?

 

I'm a complete novice at LISP routines (actually, at using AutoCAD) so any help would be greatly appreciated.

 

TommieRommie

Share this post


Link to post
Share on other sites
Shruti

I need the same code using AutoCAD vba can someone help

Share this post


Link to post
Share on other sites
BIGAL

Whats wrong with lisp ? If you want VBA can call and run a lisp.

Share this post


Link to post
Share on other sites
Shruti

I want to understand how it works in VBA

 

Share this post


Link to post
Share on other sites
Shruti
15 hours ago, BIGAL said:

Whats wrong with lisp ? If you want VBA can call and run a lisp.

Also I don't have idea of lisp

Share this post


Link to post
Share on other sites
BIGAL

Rather than restart, the solution is there in lisp you dont have to code it just load it and run, that can be done from vba likewise lisp can run a vba command.

Share this post


Link to post
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
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  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...