[Search tip detail and code files using keywords, tip number, author name, etc ]
    For tip to function correctly, you must ensure that the downloaded file name matches the file name
    displayed in the Rename File To field. Please rename downloaded files when necessary.
Attribute replacer
Tip# ALSPSOL1104 By Tony Hotchkiss On 01-Nov-2004
Rated By 1 users Downloaded : 1415
Categories : Attributed Blocks
Software type : AutoCAD
ATTRIB-REPLACER.LSP replaces attributes in the current drawing with attribute data is from a comma-delimited file exported from Access.

Kenneth Pettit e-mailed a request to take information from a Microsoft Access database and use that information to change AutoCAD attribute blocks. Kenneth has used the Automatic Attribute Extraction tool to export his attributes directly into Access. It's interesting that this is now possible to do without knowledge of the format or type of data that is being exported, and even a template file is no longer needed. Kenneth has a set of blocks that have attributes for the address and location of rooms in a building. The address codes have a format such as XX:A1-01, and they never change, but the room location values may change, and they are subject to updating in the drawing. The attributes for the room location may be updated in the Access database.
The AutoLISP Solution is ATTRIB-REPLACER.LSP, which uses a comma-delimited file exported from Microsoft Access. Any changes that have been made to the location field cause changes to be made to the corresponding attributes in the drawing. To test the code, I made a drawing with rooms and attributes for address codes and locations. I named the blocks containing the attributes ROOM-ID, although any block name can be used. The Microsoft Access table created by the Attribute Extraction tool is shown here (figure 1). The attribute values are Block name, Count, X insertion point, Y insertion point, LOCATION, and ADDRESS, as shown.

When the comma-delimited file is exported from Access (figure 2), it includes the headings. ATTRIB-REPLACER.LSP relies on the block name being in the first column, and the LOCATION and ADDRESS strings in columns 5 and 6, respectively. The other data in the table are not used, and there may be additional columns to the right of column 6.



Average Rating:

User comments