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.
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.
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
Filter in on the attribute in common I want, in this case “PART”.
Next
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
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
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
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