- Extract Block Attribute Data
To extract Block Attribute Data, first you need to create an attribute template file using any text processor, generate the attribute extraction file , and open the attribute extraction file in a database application. If you plan to extract the attribute information to a DXF (drawing interchange format) file, it is not necessary to create an attribute template file first.
NOTE: Make sure that the attribute extraction file does not have the same name as the attribute template file.
- Create an Attribute Extraction Template File
Before you extract attribute information, you need to create an ASCII template file to defining the structure of the file that will contain the extracted attribute information. The template file contains information about the Attribute name, data type, field length, and number of decimal places associated with the information you want to extract. Each line in the template file specifies/corresponds to one field to be written to the attribute extraction file, including the name of the field, the character width/length, and numerical precision. Each string in the attribute extraction file includes all the specified fields in the order given by the template file.
The template file below includes the 15 possible fields. N means numeric, C means character, www means a 3 digit number for the total width of the field, and ddd means a 3 digit number representing how many numeric decimal places are to be displayed to the right of the decimal point.
BL:NAME Cwww000 (Block name)
BL:LEVEL Nwww000 (Block nesting level)
BL:X Nwwwddd(X coordinate of block insertion point)
BL:Y Nwwwddd(Y coordinate of block insertion point)
BL:Z Nwwwddd(Z coordinate of block insertion point)
BL:NUMBER Nwww000 (Block counter; the same for INSERTBLOCKN)
BL:HANDLE Cwww000 (Block handle; the same for INSERTBLOCKN)
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 of block extrusion direction)
BL:ZEXTRUDE Nwwwddd(Z component of block extrusion direction)
numericNwwwddd (Numeric attribute tag)
characterCwww000 (Character attribute tag)
The template file can include any or all of the BL:xxxxxxx field names listed, but must include at least one attribute tag field. The attribute tag fields determine which attributes, therefore which blocks, are included in the attribute extraction file. If a block contains only some, but not all of the specified attributes, the values for the absent ones are filled with blanks or zeros (depending on whether the field is a character field or a numeric field).
NOTE:Comments should not be included in an attribute template file.
You can create/use as many template files as you like, according to your needs and/or on how you'll use the data. Each line of a template file specifies one field to be written in the attribute extraction file.
Additional guidelines:
- Be sure to place a space between the attribute tag and the character or numeric data. Use SPACEBAR, not TAB, to enter the space.
- Press Enter at the end of each line, including 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.
Here is a sample template file:
BL:NAME C008000 (Block name, 8 characters)
BL:X N007001 (X coordinate, format nnnnnn.d)
BL:Y N007001 (Y coordinate, format nnnnnn.d)
SUPPLIER C016000 (Manufacturer's name, 16 characters)
MODEL C009000 (Model number, 9 characters)
PRICE N009002 (Unit price, format nnnnnnnn.dd)
NOTE: The format code for a numeric field includes the decimal point in the total field width. For example, the minimum field width to hold the number 351.99 would be 6 and would be represented as N006002. Character fields do not use the last three digits of the format code.
- Create an Attribute Extraction File
After creating a template file, you can extract the attribute information using one of the following formats:
Comma-delimited format (CDF)
Space-delimited format (SDF)
Drawing interchange format (DXF)
The CDF format produces a file containing one record for each block reference in a drawing. A comma separates the fields of each record, and single quotation marks enclose the character fields.
The SDF format also produces a file containing one record for each block reference in a drawing. The fields of each record have a fixed width and employ neither field separators nor character-string delimiters.
DXF produces a subset of the drawing interchange format containing only block reference, attribute, and end-of-sequence objects. This option requires no attribute extraction template. The file extension .dxx distinguishes an extraction file in DXF format from normal DXF files.
- The Attribute Extraction File
The attribute extraction file lists values and other information for the attribute tags you specified in the template file. If you specified a CDF format using the sample template, the output might appear as follows:
'DESK', 120.0, 49.5, 'ACME INDUST.', '51-793W', 379.95
'CHAIR', 122.0, 47.0, 'ACME INDUST.', '34-902A', 199.95
'DESK', -77.2, 40.0, 'TOP DRAWER INC.', 'X-52-44',249.95
By default, character fields are enclosed with single quotes (apostrophes). The default field delimeter is a comma. The following two template records can be used to override these defaults:
C:QUOTE c (Character string delimeter)
C:DELIM c (Field delimeter)
The first nonblank character following the C:QUOTE or C:DELIM field name becomes the respective delimiter character. For example, if you want to enclose character strings with double quotes, include the following line in your attribute extraction template file:
C:QUOTE "
The quote delimiter must not be set to a character that can appear in a character field. In the same way, the field delimiter must not be set to a character that can appear in a numeric field.
If you specified an SDF format using the sample template, the order of the fields corresponds to the order of the fields in the template files. You can use these files in other applications, such as spreadsheets, and you can sort and manipulate the data as needed. For example, you can open an attribute extraction file in Microsoft Excel in which you can specify a separate column for each field. See the documentation for your spreadsheet program for information about how to use data from other applications. If you open the file in Notepad or another Windows text processor, you can paste the information back into the drawing as text.
- Nested Blocks
The line BL:LEVEL in a template file reports the nesting level of a block reference. A block inserted in a drawing has a nesting level of 1. A block reference that is part of (nested in) another block has a nesting level of 2, and so on.
For a nested block reference, the X,Y, Z coordinate values, scale factors, extrusion direction, and rotation angle reflect the actual location, size, orientation, and rotation of the nested block in the world coordinate system.
In some cases, nested block references cannot be correctly represented with only two scale factors and a rotation angle, for example, if a nested block reference is rotated in 3D. When this happens, the scale factors and rotation angle in the extracted file record are set to zero.
- To create an attribute extraction template file
1. Start Notepad. (You can use any text editor or word processor that can save a text file in ASCII format.)
2. Enter template information in Notepad.
3 .Save the file with a .txt file extension. To extract data about a specific tag, insert the tag name in place of the "numeric" or "character" fields.
NOTE: 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.
