If you’re creating blocks that must carry metadata (part numbers, descriptions, sheet numbers, material, etc.), the ATTDEF command in AutoCAD is the standard way to define those metadata fields — called attributes — which become editable values when the block is inserted. This guide explains what ATTDEF does, how to use it step‑by‑step, common problems and fixes, alternatives, and practical tips for production drawings.
What is the ATTDEF command?
ATTDEF (Attribute definition) creates an attribute object that stores data inside a block definition. An attribute is a text object with an associated Tag, Prompt, and Default value. When you insert the block, AutoCAD asks you to enter values for each attribute or uses the default/preset value.
Key points:
- Attributes are attached to blocks and allow storing structured information.
- Use ATTDEF before creating a block, or use it inside the block editor.
- Attribute data can be extracted to tables or external files (e.g., for BOMs or schedules).
When to use attdef (common use cases)
- You need blocks that carry editable properties such as part numbers, material, revision, or sheet numbers.
- You want to produce a parts list, material schedule, or tag list from drawing data.
- You need standardized data in blocks for BIM-like workflows or automated reports.
How to use attdef (step-by-step)
This section covers the two common workflows: using the ATTDEF dialog and using the command line prompts.
Prerequisites:
- Open the drawing where you’ll define the attribute.
- Decide the Tag name (no spaces recommended, e.g. PART_NO, QTY), the Prompt shown to the user, and the Default value.
Steps (dialog box method):
- Type ATTDEF in the command line and press Enter.
- In the Attribute Definition dialog:
- Enter Tag (e.g., PART_NO).
- Enter Prompt (e.g., Enter part number:).
- Enter Default (optional).
- Set Text options: height, style, justification, rotation angle.
- Set Mode options (see explanation section).
- Click OK. Place the attribute text at the desired position with a click. This attribute becomes a text object in Model space (or in block editor if you launched ATTDEF there).
- Create a Block that includes the attribute:
- Use the BLOCK command or open the Block Editor, select the geometry and attribute objects, and define the block name.
- Insert the block. AutoCAD will prompt for attribute values (or use default/preset values).
Steps (command-line prompt method):
- If you prefer command-line prompts, set system variable ATTDIA = 0 (dialog disabled) or use the dash-prefixed command -ATTDEF.
- Type -ATTDEF and press Enter.
- Follow the prompts in the command line for Tag, Prompt, Default, Text height, Justification, and insertion point.
- Create your block as above.
Quick example:
- Tag: SHEETNUM
- Prompt: Enter sheet number:
- Default: A1
- Place attribute, then create block named SHEET_TITLE that includes this attribute.
Example: Create a PART_NO attribute and include it in a block
- Type ATTDEF → Enter.
- In the dialog:
- Tag = PART_NO
- Prompt = Enter part number:
- Default = P000
- Text height = 2.5 (adjust for drawing scale)
- Leave modes unchecked (or set as required)
- Click OK, then click where you want the attribute origin.
- Use BLOCK to create a block named PART_MARKER selecting the attribute and any geometry.
- Insert PART_MARKER. AutoCAD asks for value for PART_NO. Enter the correct part number for each instance.
ATTDEF options and settings explained
- Tag: Unique identifier for the attribute (used in extraction and programming). Use all caps and no spaces (e.g., TAG1).
- Prompt: The user text shown when inserting a block (what AutoCAD asks for).
- Default: The value AutoCAD uses if the user presses Enter at the prompt.
- text settings: Height, Text style, rotation, and justification apply to the displayed attribute text. Use an annotative text style if you need scaling across viewports.
- Mode options:
- Invisible: Attribute is stored but not displayed in the drawing (useful if you only need data extraction).
- Constant: The attribute value is fixed and not prompted when inserting a block.
- Verify: AutoCAD prompts the user asking for confirmation after they enter the attribute value.
- ATTDIA system variable:
- ATTDIA = 1 shows the dialog box for ATTDEF.
- ATTDIA = 0 uses command-line prompts (or use -ATTDEF).
- ATTMODE system variable:
- Controls whether attribute values are displayed or only tags/placeholder text; set ATTMODE = 1 to show attribute values in inserted blocks.
- Useful related commands:
- BATTMAN — Block attribute manager (edit attributes in block definitions).
- ATTEDIT or EATTEDIT — Edit attribute values in inserted blocks.
- ATTSYNC — Synchronize all block instances when you change attribute definitions.
- EATTEXT or DATAEXTRACTION — Export attribute data to text or tables.
- ATTOUT / ATTIN — Export/import attribute data to/from a file.
Alternative methods to create or manage block data
- Use the Block Editor (BEDIT) and create attributes directly inside the block definition rather than creating them in model space and then making a block.
- Use BATTMAN to edit Tag, Prompt, Default, order, visibility, and constants across existing blocks.
- Use Fields inside blocks if you want attributes to be dynamically linked to drawing properties (but fields behave differently and are not always ideal for data extraction).
- Use Data Extraction (DATAEXTRACTION) or EATTEXT for complex reports/BOMs instead of manual copy/paste.
Common problems (attdef doesn’t work) and fixes
Problem: Nothing happens when I run ATTDEF.
- Fix: Check ATTDIA. If set to 0 and the command expects dialog input, use -ATTDEF or set ATTDIA = 1.
Problem: Attributes don’t show when I insert a block.
- Fix: Set ATTMODE = 1 to display attribute values. Also ensure attribute text is not on a frozen/off layer and text height and color are visible.
Problem: Attribute value won’t change after editing block definition.
- Fix: After changing definitions, run ATTSYNC on the block to update existing instances.
Problem: Attribute appears invisible but is present (can’t see value).
- Fix: Check Invisible mode in the attribute definition; if set, clear it to show text. Also check layer visibility, color, and text height.
Problem: Attribute values are not exported or are missing in data extraction.
- Fix: Ensure attributes have proper Tag names (unique, not blank). Use DATAEXTRACTION or EATTEXT and include blocks in the selection set.
Problem: Attribute text is too small or scales incorrectly in viewports.
- Fix: Use annotative text styles or set appropriate text height and use consistent units/scale. When creating attributes in the Block Editor, make sure size matches intended insertion scale.
Problem: Attribute behaves like constant and cannot be edited on insert.
- Fix: Edit the attribute definition via BATTMAN and uncheck Constant to allow editing on insert.
Problem: I see tags (
- Fix: Ensure the attribute Tag is not being displayed instead of value—set ATTMODE = 1 and check if the attribute was created as prompt only or using placeholders; use ATTEDIT to verify.
If none of these fixes help, check for custom scripts or third-party lisp routines that might override attribute behavior.
Tips and best practices
- Use clear, consistent Tag naming conventions (e.g., PART_NO, REV, QTY).
- Keep Tags capitalized and avoid spaces to ease extraction and scripting.
- Use Default values for common cases to speed up block insertion.
- Use BATTMAN to manage attributes centrally — it avoids recreating blocks to change attribute meta.
- Use ATTSYNC whenever you update attribute definitions in an existing block to propagate changes.
- For schedules/BOMs prefer DATAEXTRACTION over writing custom routines — it’s robust and flexible.
- Use annotative text styles for attributes that must appear correctly in multiple viewport scales.
- Test attribute behavior by creating a sample block and inserting it several times to validate prompts, defaults, and extraction.
FAQ
How do I force the attribute dialog box instead of command-line prompts?
Set the system variable ATTDIA = 1. Alternatively, use ATTDEF (dialog) vs -ATTDEF (commandline).
How can I change the attribute prompt or default after the block is already created?
Open BATTMAN (Block Attribute Manager) or edit the block definition in the Block Editor (BEDIT). After changes, run ATTSYNC to update existing block instances.
Why do attributes sometimes not show their values, only tags?
Make sure ATTMODE = 1 (show values). Also check attribute Visibility (Invisible flag), layer visibility, and that text color/height are readable.
Can I extract attribute data to Excel or a CSV file?
Yes. Use DATAEXTRACTION to export attribute data directly to a table or external file. EATTEXT can output text files with attribute values.
What’s the difference between an attribute and a field?
An attribute is stored inside a block and intended to be edited per block instance; a field can reference drawing properties and is updated dynamically. For schedule extraction use attributes. For linking text to other properties, consider fields.
How do I prevent users from changing a certain attribute?
Set the attribute Mode to Constant, so it is not prompted on insert and cannot be edited like a normal attribute value.
I changed the attribute text style but values didn’t update in existing blocks — why?
After changing attribute definitions (including text style), run ATTSYNC on the block to update all inserted instances. If needed, reinsert the block.
