- Open the Style Manager, and create a Property Set Definition that applies to Hatch objects. I called mine HatchObjects (demonstrating my incredible creativity), and will use that name in the balance of this article. If you already have a Property Set that applies to Hatch Objects, you can add the required properties to it. If you name yours differently, substitute your name for HatchObjects wherever you see it here.
- In the HatchObjects Property Set Definition, create an Automatic Property that references the Handle Automatic Property source, if one does not already exist. Select the Add Automatic Property Definition tool on the Definition tab of the HatchObjects Property Set Definition (second from the top, at the left side of the tab, with the lightning bolt icon). Select the toggle to the right of the Hatch source to put a check mark in it, then select the OK button. I chose to leave the name of the property at the default value of Handle.
- In the HatchObjects Property Set Definition, create a Formula Property.
- Enter a name for the property in the Name edit box at the top; I used HatchArea (creativity gone wild).
- Uncheck the Use formula for description toggle (unless you really want the formula to be the description; I almost never do).
- Enter the formula in the Formula edit box. If you like, you can cut and paste the formula from the code box below. Note that the [Handle] text has to be a properly created reference to the Handle Property created in Step 2. That is done by selecting it in the Insert Property Definitions pane in the lower left corner of the Formula Property Definition dialog. You can substitute that for the pasted text, or you can follow the instructions in this blog article, if you like.
Set acadApp = GetObject(,"AutoCAD.Application") Set hatchObj = acadApp.ActiveDocument.HandleToObject( "[Handle]" ) RESULT = hatchObj.Area / 144.0When done correctly, the [Handle] text will have a light gray background and will be treated as one item, not individual characters. See image of dialog below.
- The formula is setting the variable acadApp to the AutoCAD Application, and then getting the Hatch Object associated with the value of the Handle property (which is the Hatch Object to which the Property Set is attached). The RESULT of the formula is then set to the value of the Area property of the Hatch, which will be a real number representing the area of the Hatch, in square drawing units. My sample file used imperial units, with one unit equal to one inch. Since I wanted the Area value in square feet, I divided the raw value by 144.0 to get square feet. If you are not using imperial units, or want to show the Area in some other area unit, adjust the RESULT line to do what is necessary to get the area value in the desired units.
- Your Formula Property Definition dialog should look similar to the image below. If so, select the OK button to save the changes to the HatchArea Formula Property.
- Back in the Style Manager, on the Definition tab, assign the desired Property Data Format to the newly created Formula Property.
- If you need additional properties for your Hatch Objects, you can add them now. When done, select the OK button to accept the changes made, close the Style Manager and return to editing the drawing.
- Attach the Property Set to one or more Hatches in your file. Select the Hatch and note the value of the Area property (under the Geometry category) on the Design tab of the Properties palette. Then select the Extended Data tab and verify that the value shown matches (allowing for any rounding/formatting of the value by the chosen Property Data Format).
February 01, 2020
ACA: Property for Area of a Hatch Object
A question regarding tagging Hatch objects and being able to display the area of the hatch arose the other day. My initial response was, sure, that should not be a problem in AutoCAD® Architecture. Upon actually trying to do that, I found that there is no Area Automatic Property for Hatches. While that seems like an oversight, I then checked the object properties of Hatches and found that there is an Area property that is available through ActiveX. That is, no doubt, what drives the Area property of Hatches in the Properties palette. So while it was not quite as easy as I originally thought, it is possible to do, by creating a Formula Property that extracts the Area of the Hatch object to which the Property's Property Set is attached. Here is how to do that: