Extracting Block and Attribute Data

Blocks and attribute object definitions contain a great deal of data. AutoCAD automatically creates some of the data, including data that defines the block, such as the block’s name, its insertion coordinates, its insertion layer’s name, its X,Y,Z scale factors, and its X,Y,Z extrusion direction. This wealth of information can easily be extracted into a text file.

Attribute data is user-defined. The data that AutoCAD extracts consists of one element, which is either a character string or a numeric value. The attribute value can be anything the user wants it to be, and the number of attributes that can be attached to a block is unlimited.

By choosing the particular data records of blocks and the attributes you need, you can easily extract an abundance of important information from your drawing.

Using the ATTEXT Command

The command used to extract block and attribute data has been around for several releases of AutoCAD and has not changed. The ATTEXT command displays the Attribute Extraction dialog box, and is shown in Figure 9.13. The Attribute Extraction dialog box creates an ASCII text file (by default, a TXT file) containing the extracted information.

Figure 9.13. The Attribute Extraction dialog box.


This command tells AutoCAD which block and attribute information to extract and how the extracted information will be arranged. The arrangement of the information is determined by a template file (discussed later in this chapter) and the file format you select, as discussed in the following section.

Note

You can extract and link attribute data to external databases. For more information, refer to Chapter 24, “Using External Databases.”


Extraction Formats

The first item AutoCAD requests via the Attribute Extraction dialog box controls the extraction file format. The selected format determines the way each field within each record is separated and stored in the ASCII text file. AutoCAD provides three types of extraction file formats:

  • Comma Delimited File (CDF). The file format writes one record for each block on a separate line. Each data value in a record is separated from the next by a comma, with text strings enclosed in apostrophes, as follows:

     'Sewer','Manhole', 36 
    'Storm Drain','Manhole', 48 
    'Storm Drain','Manhole', 36 
  • Space Delimited File (SDF). The SDF file format also writes one record for each block on a separate line, and each data value in a record occupies a predefined field width. If the string or numeric value does not use the entire space allotted, AutoCAD fills the remainder of the field with spaces, as follows:

    Sewer          Manhole      36 
    Storm Drain    Manhole      48 
    Storm Drain    Manhole      36 
    Sewer          Manhole      36 
  • Drawing Interchange File (DXF). The DXF file format writes block data in AutoCAD’s standard drawing interchange file format. An excerpt from a DXF file created with the ATTEXT command follows:

      0 
    INSERT 
      2 
    MANHOLE 
     10 
    5.115973 
     20 
    5.442408 
     30 
    0.0 
      0 
    ATTRIB 
      1 
    Sewer 
      2 
    OBJECT_CATEGORY 
      0 
    ATTRIB 
      1 
    Manhole 
      2 

As you can see, the format options are somewhat cryptic and limited. In order to use the ATTEXT command you must have a good grasp of your data types as well as predefine a template matching your data. The following section describes an alternative to the ATTEXT command.

Using the New EATTEXT Command

A new feature added in AutoCAD 2002 makes the process of extracting data from your drawing much easier. The EATTEXT command has a step-by-step dialog interface that walks you through the process.

Each insertion has three attributes. In the following exercise, the attribute data is extracted and saved to a file.

Exercise 9.7 Extracting Attribute Data

1.
Open the drawing 09DWG04.dwg from the accompanying CD. Save the file on your local disk to anywhere you choose.

2.
From the Tools pull-down menu, select Attribute Extraction. The EATTEXT dialog appears.

3.
In the Select drawing dialog be sure the Current Drawing is selected, and then click Next.

4.
In the Settings dialog you have the options to not include external reference files or nested blocks. For this exercise it does not matter, so click the Next button.

5.
In the Use Template dialog you import a template file to help in the data query process. You don’t need one so just click the Next button.

6.
The Select Attributes dialog allows you to specify what attribute values you want to export. In this exercise file you only have one type of block, but this page can often be cluttered. Under the Attributes for Block <MANHOLE> area, click the Uncheck All button at the bottom and then check the OBJECT_CATEGORY, OBJECT_TYPE, and OBJECT_SIZE toggles (see Figure 9.14 The). Then click the Next button.

Figure 9.14 The. EATTEXT command Select Attributes dialog allows you to choose what attribute to export.


7.
The next panel is the View Output dialog. Here you can specify in which type of view you want the data to appear. You can click the Alternate View button to get a sense of the differences. Then click the Next button.

8.
On the Save Template dialog you can save out the query filter you determined in Step 6 into a Block Template File (BLK).

This is a highly recommended task if you repeat the same attribute filtering often. If you always extract information for title blocks, and your blocks have the same formatting each time, loading a saved template can speed up the extraction process.

Click the Next button to continue.

9.
The Export dialog allows you to write the attribute data out to a file. In the File Name box type in 09DWG04 . With the EATTEXT command you have four file output types from which to choose. Choose the Tab Delimited File (*.txt) and then click the Finish button.

10.
At the Enhanced Attribute Extract Alert click Yes and the system creates the file. The dialog closes.

11.
This process created a file with a TXT extension. Using Windows Notepad, browse to where you saved the file and open it (see Figure 9.15). Note that it only has the attribute settings you selected.

Figure 9.15. You can use Notepad to view saved TXT extraction files.


12.
You may close this drawing without saving.

As you can see from this section, extracting attribute and block data from AutoCAD drawings in not overly difficult with the new extraction tools. You now know what can be extracted and how to format that information.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.145.17.140