Jump to content

Batch rename with info from block attributte


pmxcad

Recommended Posts

A good day all,

 

I'm looking for a solution to the following problem. I have two hard disks I need to check for differences in the revision letter of each drawing. There are about 25 folders containing approximately 50 drawings. where I'm looking for is a lisp which gets the revision value from the TITLE BLOCK_A and put it behind the file name. Example:original file name is B00-300-800.dwg and i would have to become B00-300-800-B.dwg. The revision letter is in TITLE BLOCK_A in the TKVRIJ6 attribute. And the ability to doing it in batch using map or drawings selection?

The drawings may have different title blocks (other names) but it attribute is always the same.

I've searched the internet and found some lisps, but I do not know lisp.

Can someone help me?

 

Thank you in advance,

 

PmxCAD

B00-300-800.dwg

BatchRename.LSP

GETATT.LSP

SAVE-DWG-REV-B.SCR

Link to comment
Share on other sites

  • Replies 26
  • Created
  • Last Reply

Top Posters In This Topic

  • rlx

    15

  • pmxcad

    10

  • halam

    1

  • Silvano

    1

Top Posters In This Topic

A good day all,

 

I'm looking for a solution to the following problem. I have two hard disks I need to check for differences in the revision letter of each drawing. There are about 25 folders containing approximately 50 drawings. where I'm looking for is a lisp which gets the revision value from the TITLE BLOCK_A and put it behind the file name. Example:original file name is B00-300-800.dwg and i would have to become B00-300-800-B.dwg. The revision letter is in TITLE BLOCK_A in the TKVRIJ6 attribute. And the ability to doing it in batch using map or drawings selection?

The drawings may have different title blocks (other names) but it attribute is always the same.

I've searched the internet and found some lisps, but I do not know lisp.

Can someone help me?

 

Thank you in advance,

 

PmxCAD

 

Hi dinges,

 

It can be done , ofcourse , but allthough it's good to know the attribute name will allways be the same , you would still need to know all possible blocknames. This can be a wildcharacter as in *titleblock* , but all the ones that would not fit this filter must also be known. Otherwise you would need to itterate through each block in the drawing , get all its attributes and look if this attribute is present. But this is also a possibility I guess. You not knowing lisp does make it somewhat more difficult to give you a one size fits all solution.

 

But why would you need to save the drawings with this name , would an excell list with drawing name and revision letter not be enough?

 

Groetjes Rlx

Link to comment
Share on other sites

Hoi Rix,

 

the blocknames are: TITLE-BLOCK_A, TITLE-BLOCK_A2, TITLE-BLOCK_A1, TITLE-BLOCK_A0

 

PmxCAD

 

Ok that narrows things down , just one question , you say you need to check for differences in revision for two disks / folders. Is a list with folder/filename & revision letter enough or is it mandatory to save each file with revision letter added to the filename? You would still need to compare each file while when you have a list I think it would be more practical. But thats up to you ofcourse...

 

Gr. Rlx

Link to comment
Share on other sites

Hoi Rix,

 

the blocknames are: TITLE-BLOCK_A, TITLE-BLOCK_A2, TITLE-BLOCK_A1, TITLE-BLOCK_A0

 

PmxCAD

 

actually , 2 questions , are all the drawings in modelspace or can the titleblock also be in paperspace / multiple layouts?

 

gr. Rlx

Link to comment
Share on other sites

Can be in model space or layout, just one. And also found drawings with a titlleblock in both with different revision letters. I discover it with the dataexrtaction to excel.

So I can also use data extraction. But it takes some time to setup. Or do you know a better way to do it?

 

Pmxcad

Link to comment
Share on other sites

Can it be both? A list to compare and renaming fore later on/future.

 

Jaap

PmxCAD

 

Hoi Jaap

 

I have adapted my RlxReadTitleBlock routine. When you load it (load "RlxReadTitleBlock") it will start automaticly. You select folder with drawings , it also will search all subfolders , read all titleblocks , model and paper space and put the results in a list. When done scanning it wil try to show this list. After that it will rename all the files with revision letter added. You can disable this option in the lisp file.

 

Have done verry little testing so make a copy of your folder first

 

Gr. Rlx

RlxReadTitleBlock.LSP

Edited by rlx
Link to comment
Share on other sites

Hoi Rix,

 

Tried your lisp, not working: Processing 3 drawings...bad argument type: VLA-OBJECT nilno function definition: MDITEST_EXIT

Nothing happens, CSV file is empty except the header, and no file renamed.

also is there a row: ;the blocknames are: TITLE-BLOCK_A, TITLE-BLOCK_A2, TITLE-BLOCK_A1, TITLE-BLOCK_A0, attrib = "TKVRIJ6"

is the only row with the block names and it has a ; in front. lisp wont use this row. So there is no link with the block names.

 

 

PmxCAD

Link to comment
Share on other sites

Hoi Rix,

 

Tried your lisp, not working: Processing 3 drawings...bad argument type: VLA-OBJECT nilno function definition: MDITEST_EXIT

Nothing happens, CSV file is empty except the header, and no file renamed.

also is there a row: ;the blocknames are: TITLE-BLOCK_A, TITLE-BLOCK_A2, TITLE-BLOCK_A1, TITLE-BLOCK_A0, attrib = "TKVRIJ6"

is the only row with the block names and it has a ; in front. lisp wont use this row. So there is no link with the block names.

 

 

PmxCAD

 

Hoi Jaap,

 

Tested it again just now , no problems here. Only thingy seeing the mditest_exit is I pasted the wrong error / exit handler. Fixed this in my original post and I added vl-load-com to the init section. Normaly this is done via my acad.lsp so never have a problem myself. What autocad version are you using and if you load this routine with the visual lisp editor , what does the error watch say? (if you know how to do this)

 

btw , maybe you should not have any of the drawings you want to scan open at the time of scanning.

 

btw btw , maybe post a few example drawings aswell since i havent been able to test it on your drawings

 

gr. RLX

Link to comment
Share on other sites

Hoi RLX, still not working. Even tried other blocks and attrubutes (also changed the lisp) it gives a empty csv file only. And no names had been changed.

I can not send jou drawings, they are confidential.

 

Working (job) with acad 2014

 

 

Thanks,

Jaap

Pmxcad

Link to comment
Share on other sites

Hoi RLX, still not working. Even tried other blocks and attrubutes (also changed the lisp) it gives a empty csv file only. And no names had been changed.

I can not send jou drawings, they are confidential.

 

Working (job) with acad 2014

 

 

Thanks,

Jaap

Pmxcad

 

Hoi Jaap,

 

I wouldn't need complete drawings , just a few dwg's with title block only. I also tested it on the one drawing you did provide and no problems what so ever and I tested it also with autocad 14. It cant be write acces related I suppose because you say the csv file is created although it's empty. Is it completely empty or is at least the header created?

 

What I can do is to add more error checking in the routine for each step in the process to print a message. Really annoying for me when something is not working and I don't know why. But a few dwg's would help. You could sent me a private message so you wouldn't have to post them on the forum. Tomorrow I will try to give you a updated version with more debug info.

 

Gr. RLX

Link to comment
Share on other sites

Hoi Rlx,

Still not working, only a CSV file with a comma separated header.

 

i made 3 drawings with the original blocks. (there are more title blocks but not available this moment)

 

PmxCAD

 

Hoi Jaap,

 

I was suspecting you didn't specify the correct (title)block name and / or attribute name and now I'm sure...

 

Your border is called "KADER-DYN" and your titleblock is called "ipw-roh" with attribute "TKVRIJ6"... you gave completely wrong names...

I will post you an update later or you can try yourself if you want. Let me know...

 

If your pressed F2 (textscreen) right after your ran the routine you could have seen the message that no valid titleblocks were found.

 

gr. Rlx

Link to comment
Share on other sites

Hoi Rix,

 

the blocknames are: TITLE-BLOCK_A, TITLE-BLOCK_A2, TITLE-BLOCK_A1, TITLE-BLOCK_A0

 

PmxCAD

 

Is it possible this is how your blocks are called as a drawing but they are exploded right after insert? (exposing the underlying blocks)

 

gr. Rlx

Link to comment
Share on other sites

Hoi Jaap,

 

I was suspecting you didn't specify the correct (title)block name and / or attribute name and now I'm sure...

 

Your border is called "KADER-DYN" and your titleblock is called "ipw-roh" with attribute "TKVRIJ6"... you gave completely wrong names...

I will post you an update later or you can try yourself if you want. Let me know...

 

If your pressed F2 (textscreen) right after your ran the routine you could have seen the message that no valid titleblocks were found.

 

gr. Rlx

 

 

Sorry RLX, it did not mean to put you on the wrong track.

But they are both used in another project on the same client.

So they can therefore be used both. I must then possibly adjust the lisp.

 

Gr.

PmxCAD

Link to comment
Share on other sites

F2 message,.......

 

Command: (LOAD "D:/Mijn documenten/CAD/Nieuwe map/RlxReadTitleBlock.LSP") bad argument type: stringp nil

Command: RlxReadTitleBlock

 

Processing 3 drawings...

Couldn't connect with drawing : D:\Mijn documenten\CAD\Nieuwe map\GH1-030-800.dwg

Couldn't connect with drawing : D:\Mijn documenten\CAD\Nieuwe map\GH1-030-750.dwg

Couldn't connect with drawing : D:\Mijn documenten\CAD\Nieuwe map\GH1-030-600.dwgbad argument type: VLA-OBJECT nil

Command:

Link to comment
Share on other sites

Sorry RLX, it did not mean to put you on the wrong track.

But they are both used in another project on the same client.

So they can therefore be used both. I must then possibly adjust the lisp.

 

Gr.

PmxCAD

 

OK , no problem. If you need help let me know. You would have to make 2 adjustments to the program , (by memory) , I have a list of valid blocks , this must be updated and the part where I use something like (if (wcmatch (strcase blockname ) "TITLE-BLOCK_*") I would recomment to change into something like (if (member (strcase blockname) valid-blocknames , where valid-blocknames would need to be a global variable containing all the possible (valid) blocknames.

 

gr. Rlx

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