You can also use an attribute extraction template file to create a text file for use with database software. If you are using AutoCAD LT or an older version of AutoCAD, this method may be your only data extraction option. You can extract the data as a CDF (comma-delimited), SDF (space-delimited), or DXF file. Note: You don’t need a template to extract to a DXF (drawing interchange format) file.
To create your template file, start Notepad or a similar text editor. The template is an ASCII file that defines the structure of the file that will hold the extracted attribute information. The template file will include information such as the tag name, data type, field length, and number of decimal places.
Each field in the template file extracts attribute data from the block references in the drawing. Each line in the template file specifies one field to be written to the attribute extraction file, including the name of the field, its character width, and its numerical precision. Each record in the attribute extraction file includes all the specified fields in the order given by the template file.
Use the following format to extract information from attributes you’ve defined:
attribute_tag Twwwddd
where attribute_tag is the attribute tag, T is the data type (N indicates numeric, C character), www is a 3-digit number that sets the total width of the field (including decimal points and commas), and ddd is a 3-digit number that specifies how many numeric decimal places are displayed to the right of the decimal point.
You can also extract block information such as the following:
BL:NAME Cwww000 (Block name)
BL:LEVEL Nwww000 (Block nesting level)
BL:X Nwwwddd (x coordinate of insertion point)
BL:Y Nwwwddd (y coordinate of insertion point)
BL:Z Nwwwddd (z coordinate of insertion point)
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)
Follow these guidelines when creating a template file:
- Be sure to place a space between the attribute tag and the character or numeric data. Use the spacebar, not the TAB key, to enter the space.
- Press <Enter> at the end of each line, including the last line. Don’t include any <Enters> after the one ending the last line.
- Each attribute extraction template file must include at least one attribute tag field, but the same field can appear only once in the file.
- Do not use tab characters when constructing the template file. To align the columns, insert ordinary spaces by pressing the spacebar.
- Don’t insert extra spaces at the end of any line.
Here is a sample template file that uses some of the attributes from our earlier example
MFG C064000 (Manufacturer's name, 64 characters)
PART_NO C009000 (Part number, 9 characters)
UNIT_COST N010002 (Unit price, 10 characters, 2 decimals)
Caption: Template in Notepad.
Each row in the template becomes a column in the resulting output file. If a block contains some but not all of the attributes listed in the template file, any missing values are filled with blanks or zeros (depending on whether the field is a numeric one or a character one.
You can create any number of template files. Each line of a template file specifies one field to be written in the attribute extraction file.
Once you’ve created your template file in Notepad, save it with a TXT file extension. To extract data using your template, start the Attext command by typing Attext at the command line. In the Attribute Extraction dialog box, click on Template File and select your template file. Select the file format you want for the extraction (CDF, SDF, or DXF) and name the output file.
Caption: Attribute Extraction dialog box.
Make sure that the attribute extraction file does not have the same name as the attribute template file. Select OK to extract the attributes.
Caption: Output from template-driven data extraction.
|