Skip to Content

Linking External Data

There are many ways to extract or link information in CAD software (such as IntelliCAD and AutoCAD) to external programs or sending external data to IntelliCAD or AutoCAD drawings. This paper discusses a number of these.

Pulling data from an IntelliCAD/AutoCAD drawing (to a file)

The simplest form of data extraction is to use the ATTEXT command. This command can be used to pull information stored in attributes within blocks in a drawing. As a block symbol is inserted into a drawing, text information can be 'set' into (and associated) with an attribute stored with a block.

In other words, an attribute provides a label or tag for you to attach text to a block. Whenever you insert a block that has a variable attribute, IntelliCAD/AutoCAD prompts you to enter the data to be stored with the block. Examples of data are part numbers, prices, comments, and owners' names. Many external programs such as irrigation software, structural steel detailing programs, survey software etc. can write dwg files (or DXF files) containing blocks with text attributes.

You can associate more than one attribute with a block, provided that each attribute has a different tag. You are prompted you for the value of each attribute when you insert the block. It is also possile to define constant attributes which have the same value in every occurrence of the block. IntelliCAD will not prompt for a value when you insert the block with a constant attribute. Attributes can be invisible, which means the attribute is not displayed or plotted.

Attribute extraction

 (WARNING - don't explode a drawing with attribute data, you will no longer be able to extract it with the ATTEXT command.)

You can extract attribute information from a drawing and use that information in a CSV text file, a spreadsheet or database to produce items such as a parts list or a bill of materials (BOM).

In summary, the attribute is stored in the drawing file and can be written to an extract file by the ATTEXT command. The figure below shows a block (of a tree symbol) with attributes. Four attributes were defined, only one was made visible - the name of the tree.

 
Attributes

How to use the ATTEXT command - attribute extraction templates

You create an extraction template file which contains all of the information associated with attribute tags, such as part name, model number, cost, or supplier. After you create a template file, IntelliCAD uses that file to determine what attribute information to extract from the drawing.

Example of template file information:

Attribute tag (C)haracter or (N)umeric data Maximum field length Decimal places
Type C 040 000
Manufacturer C 006 000
Model C 015 000
Cost N 005 003

Each field in the template file extracts information from the drawing. Each line in the template file specifies one field to be written in the attribute information file, including the name of the field, its character width, and its numerical precision. Each record of the attribute information file includes all the specified fields in the order given by the template file.

The following template file displays the 15 possible fields.
BL:LEVEL Nwww000 (Block nesting level)
BL:NAME Cwww000 (Block name)
BL:X Nwwwddd (X coordinate of block insertion point)
BL:Y Nwwwddd (Y coordinate)
BL:Z Nwwwddd (Z coordinate)
BL:NUMBER Nwww000 (Block counter; same for MINSERT)
BL:HANDLE Cwww000 (Block handle; same for MINSERT)
BL:LAYER Cwww000 (Block insertion layer name)
BL:ORIENT Nwwwddd (Block rotation angle)
BL:XSCALE Nwwwddd (X scale factor)
BL:YSCALE Nwwwddd (Y scale factor)
BL:ZSCALE Nwwwddd (Z scale factor)
BL:XEXTRUDE Nwwwddd (X component of block extrusion direction)
BL:YEXTRUDE Nwwwddd (Y component)
BL:ZEXTRUDE Nwwwddd (Z component)
Numeric Nwwwddd (Numeric attribute tag)

Character Cwww000 (Character attribute tag)

The template file can include any or all of the BL:xxx field names listed. The template file must include at least one attribute tag field. The attribute tag fields determine which attributes, hence which blocks, are included in the attribute information file. If a block contains some, but not all, of the specified attributes, the values for the absent ones are filled in with blanks (if characters) or zeros (if numeric). Block references that do not contain any of the specified attributes are excluded from the attribute information file. Each field can appear no more than once in the template file.
The comment fields should not be included in the template file.

To create a template file

From the Start menu (Microsoft® Windows®), choose Programs.
From the Accessories program group, choose Notepad.
You can use any text editor or word processor that can save a text file in ASCII format.
Enter template information in Notepad and save with a .txt file extension.

To extract data about a specific tag, insert the tag name in place of the "numeric" or "character" fields.
(WARNING! Do not use tab characters when constructing the template file with a word processor. If you use tab character alignment, the attribute information file is not created. To align the columns, insert ordinary spaces by pressing SPACEBAR. The use of tab characters may cause inconsistent alignment.)

Movie here is a link to a movie which discusses these issues. This movie should play on any Windows computer provided you have installed Windows Media Player (normally installed by default).

AutoLISP programs can also be used to extract data

If you look carefully at the figure above, you may see that there is text in the drawing. If the data you require is text (in red in the figure above). If, as in this case the information is not stored as an attribute then AutoLISP would be the next tool of choice. An AutoLISP program can be used to extract the text data and write it to a CSV file. It can then be used in many different applications. In the movie which follows, we use an AutoLISP program to extract all the text from a layer (the text being placed in the drawing and at an usual angle) and write that information to a comma separated text file.

Movie here is a link to a movie which discusses these issues.

The support button in icad.net.au has a link to a discussion paper on AutoLISP.

Using the DXFOUT command

It is possible to export a DXF file from IntelliCAD or AutoCAD. If you specify an ASCII file as the DXF file, then it is possible to read the subsequent data in an external program. You might have a tool to find a cerain peice of text, extract the X and Y coordinates of that piece of text and then apss those variables to an external program such as an asset management tool.

Data to and from CAD drawings to data sources

The data link can be in either direction:

  • from the CAD software to a data source (such as information in an Excel workbook) and

  • from a data source (like an Excel workbook) to CAD software.

[The link can be static or live. If the link is live, then if data in (say) and Excel spreadsheet changes, then data in the CAD drawing will also change.] 

There are many options and different pathways. If you are contemplating building links between CAD and external data sources, we suggest that you approach the problem from a business perspective, carefully define what it is that your client requires and create a written scope for the project and get them to sign off on it. This may help sharpen your ideas and help you select the best approach to solving the problem.

Some examples of data linking are set out in the discussion under.

*** Please note that this paper is a 'work in progress' ***. 

Option 1.

The external data can be inserted as an object into an IntelliCAD drawing. The figure below, shows an Excel object to the left of a map (created in IntelliCAD) showing the location of trees in some horticultural allotments. Data about the plantings in each allotment (number of trees, variety, companion pollinating species is kept in an Excel workbook external to the CAD drawing file. So, in this case, we simply insert an object (in this case Excel, but it could be any external file source).The object link can appear in the drawing editor or can be iconized (see the circled radio button) in the insert object dialog box.

Insert Object

Once inserted as an object and the CAD file saved, a user opening the drawing can double click on the object and this opens up the spreadsheet (provided of course that a copy of Excel resides on their computer).

Double click object

Both sets of information are live; changes made to the spreadsheet data file will be seen the next time that IntelliCAD is opened and the icon double clicked.

Option 2.

It is possible to use the HYPERLINK command to connect data from CAD drawings to databases such as Excel, MS Access, FileMaker Pro etc. It is important to note that you need an up-to-date version of IntelliCAD for this to work properly. Versions of IntelliCAD (post version 6.5) implement the HYPERLINK command correctly. The command is issued, the entity that you wish to link is selected and the link established as shown in the figure below.

Hyper link 1

Once established, if there is a need to access the data associated with a particular entity, the user simply selects the entity, uses the right click mouse button and selects 'Open Link' from the pop up menu as shown in the figure below.

 Stage 2

The data then appears as shown below. In this example, the data appears in an Excel 2007 workbook.

Stage 3

Option 3:

Use the AutoLISP programming language can be used.

There are many ways use AutoLISP. At its simplest, you might use LISP to 'jump out of IntelliCAD' to a DOS shell and call the external program. So, in our horticultural example, we might put a button on a toolbar and when the user clicks the button, a short LISP program runs and calls the database program (in this case Excel) which will appear on top of the CAD drawing file in its own window.

Movie Click here to play a movie showing this technique in use.

It is also possible to use AutoLISP to read and write to data in external files and display it in the IntelliCAD text Window. We favour using simple CSV file format to store data when we use this approach.

From Excel to CAD drawing

If you want to operate in the other direction (a report from an Oracle or FileMaker Pro database for example, make sure that the report contains a link to the CAD program.

In our Example, this can be done inside an Excel sheet to open the CAD software and display a particular drawing file.

Movie Click here for an example.