Extracting and Exporting Attribute Information


After you enter the attributes in your drawing, you can extract the information contained in the attributes and use it to generate reports or to analyze the attribute data in other programs. You might, for example, want to keep track of the number and type of doors in your drawing through a database manager. This is especially useful if you have a project such as a large hotel that contains thousands of doors.

When you extract attribute data, AutoCAD creates a text file. You can choose to export the file in either comma-delimited or tab-delimited format. If you have Microsoft Excel or Access installed, you can also export the attribute data in a format compatible with these programs.

start sidebar
Common Uses for Attributes

Using attributes is an easy way to combine editable text with graphic symbols without resorting to groups or separate text and graphic elements. One of the more common uses of attributes is in column grid symbols. Attributes are well suited for this purpose because they maintain their location in relation to the circle or hexagon shape usually used for grid symbols, and they can be easily edited.

Here is a portion of the San Francisco Main Library with a typical set of grid symbols. Each symbol contains an attribute similar to the one you created earlier for the room numbers . Other symbols in the figure, such as cut lines and detail bubbles , are also blocks with attributes for text.

click to expand
end sidebar
 

 ACAD only      Performing the Extraction

In the past,extracting the attribute data from a drawing was an error-prone task requiring the creation of a template file. This template file had to contain a series of codes that described the data you wanted to extract. AutoCAD 2005 has a greatly improved system for attribute data extraction, in the form of the Attribute Extraction Wizard. The following exercises will walk you through a sample extraction.

Note  

LT does not offer the Attribute Extraction Wizard. Instead, you see the more simplified Attribute Extraction dialog box that offers the file format options (comma- or space-delimited or DXF output), the output filename, and template file options. For LT, the template file is used as an option to filter the attributes.

Using the Attribute Extraction Wizard

In this first exercise, you'll explore the Attribute Extraction Wizard:

  1. Go back to the Plan file and choose Tools   Attribute Extraction to start the Attribute Extraction Wizard. In the Select Drawing screen, you can select specific blocks for the attribute data extraction. You can also select drawings other than the current drawing. The default is to select the entire current drawing. The name of the selected drawing file appears in the list box at the bottom of the dialog box.

    click to expand
  2. Click Next to open the Settings screen. Here you can choose to extract attribute data from Xrefs and nested blocks.

    click to expand
  3. Click Next to open the Use Template screen. This screen enables you to import settings from an external file. Right now, it's not likely that you have any saved settings available, but in a later screen of the Attribute Extraction Wizard, you will have a chance to save the options you select as a template file that you can import in later Attribute Extraction sessions.

    click to expand
  4. Click Next to open the Select Attributes screen.

    click to expand

Take a moment to study the Select Attributes screen. It is the heart of the extraction process. Here you select the blocks that contain attributes as well as the specific attributes you want to extract. Notice that in the Blocks list box on the left, all the blocks in the drawing are displayed ”not just those that contain user -defined attributes. The Attributes For Block list box to the right displays attribute and block properties.

You can obtain some helpful information about your drawing just by looking at this screen. For example, you can find out how many copies of a particular block occur in the drawing by looking at the right column of the Blocks list box.

You can also add an alternate name in the Block Alias column to help better describe the block. An Alias option is also available in the Attributes For Block list box.

Selecting What to Extract

Let's continue by selecting specific information for the extraction:

  1. Click the Uncheck All button at the bottom of the Blocks list to clear the check boxes on the left side of the list box.

  2. Scroll down to the bottom of the Blocks list box and select the S-DOOR block name. Notice that the attribute list changes to show values for the selected block.

  3. Click the Uncheck All button at the bottom of the Attributes For Block list.

  4. Scroll down to the bottom of the Attributes For Block list and select all the attribute names. Remember that the attribute names are all prefixed with D-.

  5. Click Next to open the View Output screen, which displays a listing of the attribute data that you selected in the previous screen. The attribute values are shown in a table, with each block listed as a row and the attributes of the block listed in columns. You can use the horizontal scroll bar at the bottom of the list to view all the columns .

    click to expand
  6. Click the Alternate View button. The list changes so that the selected attribute data are listed individually, with one attribute per row.

    click to expand
  7. Click the Alternate View button again to return to the first view.

The first alternate offers a clearer view of the data. Notice that every door is listed. When any attribute data differs in each block, the Attribute Extraction Wizard dutifully shows the data for each occurrence of the block. But suppose all the attribute data is the same for each block. The Attribute Extraction Wizard will then consolidate the data into a more compact form.

Try the following to see how this works:

  1. Click the Back button to return to the Select Attributes screen.

  2. Go to the bottom of the Attributes For Block list and clear the checkmark next to the D-NUMBER attribute. This is the only attribute that changes for each instance of the S-DOOR block, and you are no longer extracting it.

  3. Click Next to return to the View Output screen. Now you see only a single listing for the S-DOOR block.

Because all the data is the same for each selected attribute, the Attribute Extraction Wizard lists the block name once. Notice that under the Count column it also indicates the number of times the block appears in the drawing.

click to expand

As you can see from the exercises so far, you can use the Attribute Extraction Wizard to quickly view attribute and block data without performing the entire extraction process. You can also copy the data to the Clipboard to save the data on the fly.

Saving the Attribute Data to a File

Now let's complete the extraction process. First you'll go back and restore the D-NUMBER attribute so you can get a complete listing of the S-DOOR data and then you'll extract the file:

  1. Click the Back button.

  2. In the Attributes For Block list, make sure the D-NUMBER attribute is selected, and click Next to open the View Ouput screen.

  3. Click Next again to open the Save Template screen. You might recall that earlier you had the option to recall a template file. This is where you can save a template file for subsequent recall.

    click to expand
    start sidebar
    Using a Template File

    If you prefer the older method of using a template file to determine which attributes to extract, you can do so by using the command-line version of the Attext command. Enter -Attext and follow the prompts. Make sure you have a template file ready.

    A template file is a simple TXT file that contains the tag name of the attribute you wish to extract, followed by a code indicating the type of value being extracted and the spaces required. For example, a template file containing D-NUMBER C005000 tells AutoCAD to extract the D-NUMBER attribute. The code C005000 tells AutoCAD that D-NUMBER is a character value (C) that needs 5 spaces (005). The three zeros at the end are required placeholders. If the value is numeric, the code would be N005001, where N denotes a numeric value, 005 denotes the number of spaces, and 001 denotes the number of decimal places required. Each attribute entry requires a line in the template file.

    end sidebar
     
  4. Click Next to open the Export screen. This is where you specify the filename and type of file you want to extract.

    click to expand
  5. Click the File Type drop-down list and take a moment to study the options. Notice that you can save the exported data as comma-delimited text (.csv) and tab-delimited text (.txt). If you have Microsoft Office installed on your computer, you may also see Microsoft Excel (.xls) or Microsoft Access Database f (.mdb). Select the Tab Delimited (*.txt) option.

  6. Click the ellipsis ( ) button to the right of the File Name input box to open the Save As dialog box. Enter Planattribute in the File Name input box.

  7. Using the Save In drop-down list, locate the folder where you are storing your sample files for the exercises in this book, and click Save.

  8. Back in the Export screen, click Finish to return to your drawing.

You now have a file called Planattribute.txt that contains the data you saw earlier in the View Output screen of the Attribute Extraction Wizard. You can import that data into any program that will accept a tab-delimited data file, including database, spreadsheet, and word-processing programs.

Using Extracted Attribute Data with Other Programs

In step 6 of the previous exercise, you also had the option to save the file in a CSV, or comma-delimited, format. This format is common to many Microsoft Office products. If you have Microsoft Excel or Access, you can also export files to the native formats of these programs.




Mastering AutoCAD 2005 and AutoCAD LT 2005
Mastering AutoCAD 2005 and AutoCAD LT 2005
ISBN: 0782143407
EAN: 2147483647
Year: 2004
Pages: 261
Authors: George Omura

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net