Jump to content

Lisp routine use csv to update title block attributes - on ctab


HRae

Recommended Posts

Hi Folks,

First time here and I have read all forums about lisp, block attributes, csv and other editing.

By virtue of working in many different companies, I have come across an 'update' lisp routine that takes title block attribute information from a csv file and updates all title blocks.

The problem I now have is that I have mulitiple drawings on layouts (ctab) and the current version of the lisp routine doesn't allow for this arrangement.

A copy of the lisp routine is attached below. I thank Paul Fylink for creating this in the first place.

 

If any one can help out with amending this, I would be most appreciative.

 

Thank you in advance.

 

Heather

update.lsp

Link to comment
Share on other sites

  • Replies 116
  • Created
  • Last Reply

Top Posters In This Topic

  • Lee Mac

    31

  • HRae

    26

  • SteveK

    17

  • johmmeke

    15

Top Posters In This Topic

Posted Images

Hi, Judging by the response if you still need a solution to this you might try attaching a couple of drawings of what you want and what happens instead.

And can you edit your above post and put

 brackets around all your code so it doesn't appear so overwhelming at first glance?

And lastly, I don't suppose asking Paul Fylink to edit it is possible?

Link to comment
Share on other sites

Hi Steve,

 

I didn't know how to attach the lisp as others have done.

Also as mentioned, this lisp was modified by Paul F (and I don't know how to contact him), but further investigation it appears that he took something similar to the Pat.zip lisp routine in another thread and modified it.

Note that we don't use all aspects in the routine.

Basically we have an exell spreadsheet with all the block attributes of our title block, create a csv file that the lisp routine reads and then updates the attributes in the title block. This worked fine if we had an Autocad file for every drawing, I now want to use the above approach but have the ability to update blocks on different layouts.

The update of attributes only allows for one block to be inserted into the drawing, therefore now that I have layout (ctab), I get error messages that "more than one block was found only updated first occurance".

Attached is the drawing file with 2 layouts, the txt file is used in the lisp routine to locate the csv file (currently zipped to allow upload).

 

If you can modifiy or provide an alternative lisp that works, that would be good.

Thanks

Heather

4431-21-002.dwg

_Dwglistcsv.txt

Test_Document Control.zip

update.lsp

Link to comment
Share on other sites

Hi Heather,

 

Seeing as all the more experienced lisper's have left this one I've had a look at it and I think it'll be a fair bit of work for me to modify it to suit multiple layouts. So I'm going to plan B: There are a couple of global attribute edit programs out there that could be rigged to do what you want. However, also to limit the work I am wondering how hard it is for you to modify your csv file to output in a form like:

ATTRIBUTE_NAME_1,ATTRIBUTE_STRING_1

ATTRIBUTE_NAME_2,ATTRIBUTE_STRING_2

ATTRIBUTE_NAME_3,ATTRIBUTE_STRING_3

Otherwise I'll have to try figure out or extract the method used by Paul Frylink and I'm just a little busy this week.. let me know.

 

steve

Link to comment
Share on other sites

Hi Steve,

 

I can happily change it, if you can offer some assistance as to 'how'. Currently the csv file is created by using the 'save as' from excell. Changing the csv file, I'm assuming that all I should need to do is update all the columns in the spreadsheet to match exactly the block attribute names.

I will give it a try and see if that can resolve the issue.

 

Also as mentioned, I think the origin of the lisp came from a previous lisp (refer zipped file). However this is in French and the translate doesn't work that well. I will also try to find the orginal thread where this came from.

There maybe some valuable insite if you read this thread (I don't have the knowledge to write lisp routines) page 8 of the thread may help out.

http://www.cadtutor.net/forum/showthread.php?t=33971

 

Also, there is no rush for this, it is a work in progress to get these changes occuring in my new office.

 

Thanks for your help to date.

 

Regards

Heather

 

PS - found the ALSPSOL0708.zip file that says it does this:

 

;;; ATT-TABLE-UPDATE.LSP A program to update a drawing with blocks ;;;

;;; and attributes. The data comes from an EXCEL file (comma- ;;;

;;; delimited), and the blocks may be added, repositioned or ;;;

;;; deleted. A table of the blocks is also created or updated. ;;;

;;; Program by Tony Hotchkiss May 2008

 

Instead of modifing the current lisp I have, if you have another lisp routine that will do the same thing, then I'm happy to take that on.

Pat.zip

ALSPSOL0708.zip

Link to comment
Share on other sites

You don't need to work out a new format for the CSV file if I can just work out where the attribute's TAG is in relation to the attribute's STRING in the CSV file (If you open the CSV file in notepad (so it has all the comma's, this is what I'm trying to work a formula out for)). But yeah, I'll have a look at it (bit busy at the moment) and if I can't figure it out I'll try get the code from the old lisp.

Link to comment
Share on other sites

I was going to attach the spreadsheet as a zip file, but it is too large for the forum. I also don't know the forums policy about contacting members directly. Please let me know if you want the spreadsheet and how to get it to you.

Link to comment
Share on other sites

Heather, can you post me a couple of other examples of CSV files you export? As varying as you can find (I notice in the CSV files you have Electrical, Geotechnical, Landscaping, etc). Ta.

Link to comment
Share on other sites

Hi Steve,

 

The intention is to have the ability to update both multiple layouts and mulitple drawings. But the way the update works is that when ever a drawing is opened, then the csv file will be read and the latest information (revision's) will be shown, regardless if the title sheet (and hence drawing) be a single layout or multiple.

We don't need the ability to run the lisp to update all drawings at the push of a button (but would be nice). As I see it, if the update occurs when opening, then when ever the drawing is printed or published then the correct revision will be present.

The xls file is used to manage all the information (change new revs etc here first) then write the csv file so that the lisp routine gets the new information.

Attached are 3 small projects, the sub headings that you see can be added, but in most instances the projects I now work on don't need these. I have added a file of a really large project so you can get both aspects.

Note that the xls files have over time improved, so there are some really early versions which are very basic.

 

Heather

CSV XLS FILE 1.zip

CSV XLS FILE 2.zip

CSV XLS FILE 3.zip

Large project Document Control.zip

Link to comment
Share on other sites

Hi Steve,

 

The routine works and updates all the title block information in each layout, but unfortunitely it repeats the first set of information across all blocks.

The problem maybe with the xls spreadsheet as each line is portrayed as a single drawing.

From my investigation of the original lisp, it appears to take all this xls information and pull it together to identify what drawing to open and then to apply the title block information. I don't know if this area of the lisp can be extended to search for the 'ctab' information also.

For example spreadsheet creates drawing 004, but this is a layout, therefore the lisp routine looks for 4431-21-004 drawing file (but there isn't one) it is 4431-21-002 drawing, but layout (ctab) 004.

 

As mentioned, no rush for this and I thank you for all your help. I just hope that with this routine that you and others can make use of it.

 

I have no other ideas at present to get this working.

 

Heather

Link to comment
Share on other sites

Ok, I wasn't aware that the first item also lists the layout. (I'm still trying to piece parts of this together :)) So the last 3 numbers relating to layouts is just a new thing in the xl/csv file? And if so will it be common and always 3 numbers? Because the lisp would probably have to split the number between the drawing filename and the layout name, and if it was a common length or if it was always whatever follows the last "-" then that would make that bit easy.

 

As for the rest, I'll have a think about it, since you're not in a rush and it's just me workin on it beta2 might not be straight away. :geek:

Link to comment
Share on other sites

What I have done is name the layout tab to match the drawing number in the title block, so there maybe a way instead of the lisp routine getting the variable (drawing number), it could get the variable ctab. Apparently autocad reads (distinguishes) all layouts as a 'new' drawing (guessing here after speaking with a colleague).

The ctab layout number will always be the 3 digit extension of the drawing name/title and in some instances the drawing file.

 

Hope this makes sense. Yip, no rush as mentioned. :D

 

Do you think if I phase my question in another way on a new thread, there maybe someone else out there with some ideas?

Link to comment
Share on other sites

Do you think if I phase my question in another way on a new thread, there maybe someone else out there with some ideas?

I think we'll be able to get your multiple layouts sorted however I haven't touched your multiple drawings (I was looking at this program recently - whether you can combine it with the one you got you'd need to ask) so yeah if you want to try on a different forum go ahead (I still think people are put off by your massive first post (you can still edit it to put [CODE][/CODE] brackets around it which will make it smaller))

Link to comment
Share on other sites

Heather what will the drawing file be named? Because the one you attached near the start contains the layout name as well, however the actually drawing also contains a layout called 003? Is the drawing file named correctly? If so, then the drawing file always contains the name of the first layout in its' name?

Ta.

Link to comment
Share on other sites

Hi Steve,

 

When you have time, can you look at the section of the lisp that runs (defun do-atts ()

 

From me experimenting with inserting the getvar "ctab" expression instead of the getvar "dwgname" I think this is where the lisp can look for the dwgname and then the layout.

 

Due to my limited knowledge, I don't know how to modify the line to add the ctab into the request.

(if (= (strcase (strcat csv-cell ".dwg")) (strcase (getvar "dwgname")))

 

I notice when changing the dwgname to ctab, the error message of 'can't find dwg ....' comes up.

 

Let me know your thoughts. :)

 

I found a diesel expression to get the ctab information, but don't know how it could be used in this instance

$(substr,$(getvar,ctab),1,$(-,$(strlen,$(getvar,ctab))))

Heather

Link to comment
Share on other sites

Yep I made a few modifications to the function do-atts.

 

Can you tell me what you found wrong with v2 (post #17)? Did it not recognize the drawing name? I tried to implement the layout name (tab) into the program changing the drawing you gave me (post #3) from 4431-21-002.dwg to 4431-21.dwg because I assumed the last 3 digits refers to the layout name (which varies for multiple layouts/tab in a single drawing). The test I ran on that specific drawing seemed to work (to a degree) so if possible can you try it on a few drawings and let me know what problems you find (include the drawing name and layout names in your problem report).

 

steve

Link to comment
Share on other sites

The latest lisp revision opens up the autocad drawing (xxxx-xx-3 digits), if I change the drawing file to be xxxx-xx-2 digits, error message that drawing not found occurs. Renaming layouts to either 2 or 3 digits appears to have no impact on lisp routine.

 

I have attached 2 images to show the xls and dwg. From the xls image, the information for xxxx-xx-002 drawing is put into the title block on all 3 layouts (even through ctab are 002, 003, 004).

 

Meaning title block information assocated with 002 in xls is repeated for all title blocks in the dwg.

 

Heather

XLS.jpg

Dwg.jpg

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