Lee Mac Posted January 12, 2011 Share Posted January 12, 2011 (edited) Hi All, Following an idea posed in this thread, I have created the following code to enable a user to automatically update titleblock attributes using data sourced from a CSV Drawing Register, a file which may be created using the DataExtraction command. The code is designed to be as generic as possible to benefit the majority of users. The location of the CSV Drawing Register may be entered at the top of the code, or this may be left nil (current setting), in which case the user is prompted for selection of a CSV Drawing Register from which attribute data will be sourced. The code also comes equipped with an optional block filter, located at the top of the code. If nil, the code will update all attributed blocks with attribute tags matching those listed in the headings of the CSV Drawing Register. The block filter may also use wildcards: e.g. "*BORDER". An example of the expected format of the CSV Drawing Register is as follows: +------------+-----------+----------+----------+-----+----------+ | DWG | Layout* | TAG1 | TAG2 | ... | TAGN | +------------+-----------+----------+----------+-----+----------+ | Drawing1 | Layout1 | Value1 | Value2 | ... | ValueN | +------------+-----------+----------+----------+-----+----------+ | Drawing1 | Layout2 | Value1 | Value2 | ... | ValueN | +------------+-----------+----------+----------+-----+----------+ | Drawing2 | Layout1 | Value1 | Value2 | ... | ValueN | +------------+-----------+----------+----------+-----+----------+ | ... | ... | ... | ... | ... | ... | +------------+-----------+----------+----------+-----+----------+ *Layout column is optional. Where the first column contains drawing filenames (with or without extension). The second column is an optional 'Layout' column for drawings containing different titleblock information on different layouts. Change the setting at the top of the code if the CSV Drawing Register contains a Layout column next to the Drawing Filename Column. The remaining columns contain the corresponding values of those attribute tags listed in the first row. A Short Demonstration The code is currently geared to run upon being loaded to enable users to add the code to either the Startup Suite or ACADDOC.lsp (see here for information about doing so), and hence automatically update titleblock attribute information whenever a drawing file is opened. This 'autorun' functionality can easily be disabled as described in the code header. Please read the code header for more information, and, if you have any questions about the code, please don't hesitate to ask. Regards, Lee A full description of the program including example CSV Drawing Register demonstrating the correct format can be found here. UpdateTitleblockV1-9.lsp Edited September 18, 2016 by Lee Mac Updated code. Quote Link to comment Share on other sites More sharing options...
irneb Posted January 13, 2011 Share Posted January 13, 2011 Lee, could you add as an optional 2nd column the Layout tab? I.e. if the 2nd column of the CSV is headded by the word "Layout" you should use (410 . "LayoutName") in the ssget filter, and start reading the tag values from the 3rd column. Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted January 13, 2011 Author Share Posted January 13, 2011 Lee, could you add as an optional 2nd column the Layout tab? I.e. if the 2nd column of the CSV is headded by the word "Layout" you should use (410 . "LayoutName") in the ssget filter, and start reading the tag values from the 3rd column. That's a nice idea Irne - I might add that as another option at the top of the code Quote Link to comment Share on other sites More sharing options...
CADkitt Posted January 13, 2011 Share Posted January 13, 2011 Cool and I too thought about the layout the problem I had with that idea was that it then had to go to every layout, and that took a lot of time, and I didn't really needed it. Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted January 15, 2011 Author Share Posted January 15, 2011 Lee, could you add as an optional 2nd column the Layout tab? Cool and I too thought about the layout the problem... Code updated to allow for 'Layout' column next to the Drawing Filename Column - the setting for this is located at the top of the code. Enjoy! Lee Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted May 19, 2011 Author Share Posted May 19, 2011 Updated the first post with the latest program code, and added a better description of this program including example CSV Drawing Register to my site here: http://lee-mac.com/updatetitleblock.html Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted August 28, 2011 Author Share Posted August 28, 2011 I have updated this program to Version 1.2. This version removes the case-sensitivity from the 'Drawing filename' column (first column) of the CSV Drawing Register. This was an oversight in previous versions, brought to light following reports from some users that drawings could not be found in the CSV Drawing Register. I have also added a GIF animation to provide a short demonstration of how to use the program to link drawings to a CSV Drawing Register, synchronising the titleblock attributes. A full description of the program can also be found on my site here, along with the latest version. Lee Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted September 18, 2012 Author Share Posted September 18, 2012 I have updated this program to Version 1.5; the new version of the code revises the CSV file parser function to account for the use of alternative cell delimiter characters (such as a semi-colon) used by some systems. The latest version can be found in the first post of this thread, or on my site here. Lee Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted May 22, 2013 Author Share Posted May 22, 2013 Following a reported bug concerning parsing of CSV cell values containing a certain combination of commas & quotation marks, I have updated this program to Version 1.6; the latest version can be found in the first post of this thread, or on my site here. Enjoy, Lee Quote Link to comment Share on other sites More sharing options...
Astro Posted September 29, 2014 Share Posted September 29, 2014 Hey Lee, I've been using this lisp a lot and saved me a lot of time, thank's for this. Today i need to import russian and chinese text to my title block but it looks like it's not supporting it. I get only question marks imported. into the title block. In the CSV it's displayed correctly. Is it possible to support this in your lisp? Here is example of what i'd like to import: КЛЮЧЕВОЕ МЕХАНИЧЕСКОЕ ОБОРУДОВАНИЕ Many thanks in advance for your help! Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted September 29, 2014 Author Share Posted September 29, 2014 Hi Astro, I'm pleased to hear that you find this program useful in your work! Is it possible to support this in your lisp? It is not possible using the standard AutoLISP functions for reading/writing text files (i.e. open/read-line/write-line/close), since these are designed to support only ASCII characters. However, a client contacted me some time ago with the same request, and I was able to develop a version of the program which read the CSV file as a binary stream, before converting the stream to Unicode code points. However, this is a much slower method and also quite temperamental. Needless to say, this version of the code is not freeware. Lee Quote Link to comment Share on other sites More sharing options...
BlackBox Posted September 29, 2014 Share Posted September 29, 2014 Always neat to see the ideas you implement (first time seeing this). Curious to know how this stacks up against Sheet Set Manager (SSM) propagation in your testing, in terms of performance? Cheers Quote Link to comment Share on other sites More sharing options...
Astro Posted October 1, 2014 Share Posted October 1, 2014 Thank's a lot for your reply, good to know that the standard Autolisp functions are only supporting ASCII Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted October 1, 2014 Author Share Posted October 1, 2014 Always neat to see the ideas you implement (first time seeing this). Thanks BlackBox Curious to know how this stacks up against Sheet Set Manager (SSM) propagation in your testing, in terms of performance? The SSM is most probably a far more elegant & recommended solution for this task seeing as it makes use of OOTB functionality, though, unfortunately I really couldn't offer any comparison, as this is one of the few areas of AutoCAD to which I have not yet ventured. Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted October 1, 2014 Author Share Posted October 1, 2014 Thank's a lot for your reply, good to know that the standard Autolisp functions are only supporting ASCII You're welcome Astro! Quote Link to comment Share on other sites More sharing options...
jjaili Posted December 16, 2014 Share Posted December 16, 2014 Hi Lee, Great program, very helpful. I do have a problem where attributes in a dynamic block (visibility parameter only) are not updating. If I remove the visibility parameter, the attributes update just fine. Is there something I am doing wrong or does this program not work with dynamic blocks? I have checked everything I can think of (locked location, annotative scale, layers, etc.). I am not controlling the visibility of the attributes with the visibility parameter. I leave the attribute blank if I do not want it visible. I would appreciate any help you can provide. Thanks. Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted December 29, 2014 Author Share Posted December 29, 2014 Great program, very helpful. I do have a problem where attributes in a dynamic block (visibility parameter only) are not updating. If I remove the visibility parameter, the attributes update just fine. Is there something I am doing wrong or does this program not work with dynamic blocks? I have checked everything I can think of (locked location, annotative scale, layers, etc.). I am not controlling the visibility of the attributes with the visibility parameter. I leave the attribute blank if I do not want it visible.I would appreciate any help you can provide. Thank you, I'm pleased that you find the program useful. The program should be compatible for use with dynamic blocks since the program updates the attribute values based on the attribute tag name and not the block name (which could potentially be anonymous where dynamic blocks are concerned). Are you using the latest version of the program? (Version 1.7) Have you changed the block filter parameter? (Line 103) Lee Quote Link to comment Share on other sites More sharing options...
jjaili Posted January 2, 2015 Share Posted January 2, 2015 We had changed the block filter to "* Attributes" and it worked for all blocks ending in " Attributes" except for the dynamic block. I changed the block filter to "nil" and it now works with the dynamic block also. I was using Version 1.6 and wanted to see if I could correct the problem before upgrading to Version 1.7. Thanks for your help. I have learned a lot from your website. Joel Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted January 3, 2015 Author Share Posted January 3, 2015 We had changed the block filter to "* Attributes" and it worked for all blocks ending in " Attributes" except for the dynamic block.I changed the block filter to "nil" and it now works with the dynamic block also. I was using Version 1.6 and wanted to see if I could correct the problem before upgrading to Version 1.7. Thanks for your help. I have learned a lot from your website. Joel You're very welcome Joel, I'm pleased that you found my website useful. Since dynamic block references assume an anonymous block name when the dynamic parameters are altered from that of the block definition, the block filter parameter in my program would need to be changed to: "`*U*,* Attributes" in order to include such dynamic block references. Lee Quote Link to comment Share on other sites More sharing options...
Bobzy20 Posted January 15, 2015 Share Posted January 15, 2015 Hi I’ve just started using this code today. Although I’m not sure how to get the code to run automatically when I open the DWG file. I’m using the sample DWG and Sample CSV files. I’ve loaded the UpdateTitleblockV1-7.lsp into my Startup Suite. I open the Sample CSV file and make my changes to the Tag cells and save. When I open the DWG file nothing happens, I then have to run the UTB command and go and find the location of the Sample CSV file. How can I get it to update the DWG just by typing UTB in the command line like the Demonstration video? Thanks Bob Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.