April 9th, 2010 | Published in Google SketchUp
In the picket fence example, I used attributes (Length, Width, etc) that pre-exist for every group and component SketchUp creates. I didn't need to add any of my own attributes to do the calculations I wanted; the information I needed was included in the generated report automatically.
With SketchUp Pro, it's easy to add your own custom attributes to groups and components. Taking the fence example, I'd like to make it easier to do two things when I design a fence and generate a report:
- estimate construction costs
- estimate how much paint I'll need to paint the fence
I'll use the Post component to illustrate what I'm doing. Each post is 5.5 feet long. 4x4 lumber (from which the posts will be cut) is available in 8, 10, 12 and 16 foot lengths; of these, buying 12 foot lengths will result in the least waste and therefore the lowest cost. Since a 12 foot 4x4 costs $16.97 and yields 2 posts, the cost of a single post is $8.48.
To add a custom Cost attribute to my Post component, I do the following:
- Select an instance of the Post component in the model.
- Right-click on the component and choose Dynamic Components > Component Attributes from the context menu.
- Click Add attribute in the Component Attributes dialog box and type Cost, then hit Enter.
- In the blank field (box) next to the word "Cost", type =8.48 and hit Enter.
Now my Post component includes a custom attribute called Cost whose value is 8.48. This value is fixed; it isn’t based on a formula that includes other values. Adding a formula here is entirely possible, though. If Cost could be calculated based on another attribute (like LenZ, perhaps), it would make sense to enter a formula that does just that. If lumber were $1.43 per linear foot, the formula might look like this: =LenZ*1.43
Adding a custom Area attribute to estimate paint quantity
In order to be able to estimate how much paint I'll need to cover my fence, I need to calculate its surface area. Luckily, the Component Attributes dialog box includes a handy function that makes this relatively easy: FACEAREA returns (calculates) the total surface area (in square inches) of a given material in any component. If you don't specify a material, FACEAREA returns the total surface area of every face in your component -- both sides of every face, actually. To get the surface area of just the outside (where you're most likely to paint), all you have to do is divide by 2. To convert square inches to square feet, divide by 144.
To add a custom Area attribute, here's what I do:
1. Select an instance of the Post component in the model.
2. Right-click on the component and choose Dynamic Components > Component Attributes from the context menu.
3. Click Add attribute in the Component Attributes dialog box and type Area, then hit Enter.
4. In the blank field (box) next to the word "Area", type =(FACEAREA()/2)/144 and hit Enter.
Of course, the area shown by my new Area attribute is bigger than the area I actually plan to paint; it includes the part of the post that's buried underground. If I'd wanted to be more precise, I could have included something in my formula that accounted for this. I'd rather buy more paint than I need, so I'll leave it as-is.
Using custom attributes in reports
Any custom attributes you add to a group or component automatically appear in your reports. After adding the Cost and Area attributes to my Post component, generating a report (File > Generate Report...), and deleting the attribute columns I don’t need, here’s what I end up with:
It bears mentioning that adding custom attributes to your components before you start modeling with them makes things easier. If you add a formula-based custom attribute to a single instance of a component, you might need to redraw (Right-click > Dynamic Components > Redraw) each additional instance separately to get it to update.
Posted by Aidan Chopra, SketchUp Evangelist