AutoCAD Tip – Reference a Block Count in a Field

I received a question from a Between the Lines blog reader John Reid this week in response to a previous post “StarBacks BBQ Floor Space Planning with AutoCAD FIELDS”. I thought it would be a great lunchtime challenge to break free of all the other things I was doing, and have some CAD geeky fun.

The question was about having a field read a block quantity in the drawing.

I received a question from a Between the Lines blog reader John Reid this week in response to a previous post “StarBacks BBQ Floor Space Planning with AutoCAD FIELDS”. I thought it would be a great lunchtime challenge to break free of all the other things I was doing, and have some CAD fun.

The question was about having a FIELD read a BLOCK quantity in the drawing.

I created this tutorial showing how I accomplished this challenge. There could be other ways, but this was the method I used and came natural to me.

I used BLOCK ATTRIBUTES in the BLOCK definitions, in this case an ATTRIBUTE named “PART”. This way I could get both the BLOCK name as well as the part name. With the BLOCK definitions I could then use the Data Extraction wizard to export the BLOCK ATTRIBUTES and block counts to an AutoCAD TABLE. I could then have the table as my BLOCK counts and reference the cell in the table in a field elsewhere in the drawing. Now if I deleted one of the instances of the BLOCKs, the counts would magically be updated to reflect the true count of BLOCKs,

Note in order for the TABLE count to update frequently when you save the file and in turn update the fields you need to have your system variable DXEVAL set to 32 so that the value updates when the drawing is saved.

OK lets step through this visually.

AutoCAD 2010 Tip: Count Blocks with a Field
I have a drawing in AutoCAD 2010 with a HVAC design for a building. I setup 2 blocks one for a specific HVAC return and one for diffusers with a attribute of PART in the block editor. The blocks were inserted multiple times throughout the design.

AutoCAD 2010 Tip: Count Blocks with a Field

Now I start the Data Extraction wizard and have it automatically select all content. After saving a extraction template, select the option to display blocks with attributes only.
Next

AutoCAD 2010 Tip: Count Blocks with a Field

Filter in on the attribute in common I want, in this case “PART”.
Next

AutoCAD 2010 Tip: Count Blocks with a Field

Select the option to create a table from the data. It will create the block properties I selected as well as a total count per block with the default option for count to display.
Next

AutoCAD 2010 Tip: Count Blocks with a Field 

Now that I have inserted the generated table, I can create a FIELD to reference the cells in the table that contain the block counts.
Next

AutoCAD 2010 Tip: Count Blocks with a Field

I use insert FIELD and select formula and then select the option “cell” and then select the cell in the table I want to display in the FIELD.
Done

AutoCAD 2010 Tip: Count Blocks with a Field

Now I have both a table with block count and attributes as well as a field referencing the table cells. The best of both worlds. I could place the field in a label elsewhere in the drawing instead of a table format.

I linked to the online AutoCAD Help (http://www.autodesk.com/autocad-help) documentation for certain terms and commands in this blog article.

Thanks to John Reid for giving me the fun challenge.

Cheers,
Shaan

Shaan Hurley
Shaan Hurley
Articles: 4656

26 Comments

  1. Cannot seem to get by (Page 2 of 8) in the DE Wizard. I’ve selected the (Drawings/Sheet set) with (Include current drawing) options as well as (All Objects in drawing) from the settings dialog.
    As soon as I select “Next”, a dialog box opens for a split second that loads the file, but the DE Wizard remains on page 2 and will not advance to the next page.
    Any ideas?

  2. Cannot seem to get by (Page 2 of 8) in the DE Wizard. I’ve selected the (Drawings/Sheet set) with (Include current drawing) options as well as (All Objects in drawing) from the settings dialog.
    As soon as I select “Next”, a dialog box opens for a split second that loads the file, but the DE Wizard remains on page 2 and will not advance to the next page.
    Any ideas?

  3. It asks me to save the settings file on (Page 1 of 8), which I have already done. The only way I can get past page 2 is to pick the (Select objects in the current drawing) option, then make a selection set. The problem with this method is if you add blocks to the drawing, they will not be part of the selection set, therefore the quantities do not update in the table.

  4. It asks me to save the settings file on (Page 1 of 8), which I have already done. The only way I can get past page 2 is to pick the (Select objects in the current drawing) option, then make a selection set. The problem with this method is if you add blocks to the drawing, they will not be part of the selection set, therefore the quantities do not update in the table.

  5. The formula/cell field only seems to allow numeric values to be referenced. Is there a way to reference a text entry from a cell?

  6. The formula/cell field only seems to allow numeric values to be referenced. Is there a way to reference a text entry from a cell?

  7. I too would like to know how to get the text from a table cell into a field.
    Please respond here if you have found a solution.

  8. I too would like to know how to get the text from a table cell into a field.
    Please respond here if you have found a solution.

  9. If using the method I mentioned to select insert Field and use formula then just pick in the cell or reference the cell and you are good to go.
    Here is my example it created when I selected a cell in the table: Table(2129725320).A3

  10. If using the method I mentioned to select insert Field and use formula then just pick in the cell or reference the cell and you are good to go.
    Here is my example it created when I selected a cell in the table: Table(2129725320).A3

  11. It is only working for numeric values, not text. If I link it to a cell with text the field shows “####”, if I change the cell to a numeric value and just do REA (regen all) without changing anything with the field it will display the numeric value I’ve entered into the cell. But once that cell contains any text it reverts back to “####”.
    I’m using AutoCAD 2010. My goal is to get a Cell of text into a field of a block, so if the table is changed the blocks field(s) update from the table. The numeric values work flawlessly, but it does not seem to work with alpha or alpha-numeric values.
    Thanks in Advanced,
    Billy

  12. It is only working for numeric values, not text. If I link it to a cell with text the field shows “####”, if I change the cell to a numeric value and just do REA (regen all) without changing anything with the field it will display the numeric value I’ve entered into the cell. But once that cell contains any text it reverts back to “####”.
    I’m using AutoCAD 2010. My goal is to get a Cell of text into a field of a block, so if the table is changed the blocks field(s) update from the table. The numeric values work flawlessly, but it does not seem to work with alpha or alpha-numeric values.
    Thanks in Advanced,
    Billy

  13. I’d be interested in finding out how to get this to work to do furniture counts using dynamic blocks (i.e. 1 block that can be either a 2 seat, 3 seat or 4 seat table with an attribute associated with each option and being able to break the associated information out on a schedule that shows number of 4 seat tables and total number of seats that equals)

  14. I’d be interested in finding out how to get this to work to do furniture counts using dynamic blocks (i.e. 1 block that can be either a 2 seat, 3 seat or 4 seat table with an attribute associated with each option and being able to break the associated information out on a schedule that shows number of 4 seat tables and total number of seats that equals)

  15. Thankyou so much, this post is 3 years old as of now but it still just helped me. I was going through LISP hell trying to count the total number of layouts so I could count total amount of pages in a project and then display the info in a field. I’d previously used the count in EATTEXT to count an invisible attribute in my title block but could not for the life of me think of how to bring it into my “page x of x” as a field without programming. so easy! Sometimes you forget the easy stuff and go for the hard solution.
    now, i’ll just write a script that every time I regen it will update datalinks, run some lisp and then finally do the regen….

  16. Thankyou so much, this post is 3 years old as of now but it still just helped me. I was going through LISP hell trying to count the total number of layouts so I could count total amount of pages in a project and then display the info in a field. I’d previously used the count in EATTEXT to count an invisible attribute in my title block but could not for the life of me think of how to bring it into my “page x of x” as a field without programming. so easy! Sometimes you forget the easy stuff and go for the hard solution.
    now, i’ll just write a script that every time I regen it will update datalinks, run some lisp and then finally do the regen….

Leave a Reply

Discover more from Between the Lines Blog

Subscribe now to keep reading and get access to the full archive.

Continue reading