Calculate Nested Attributes works with the Component Attributes window, and offers two new functions that calculate attribute values in nested components and groups, and updates them dynamically.
=NestedAttributeSum("attribute_name", "attribute_dictionary"{optional})
- sum of all attributes with name "attribute_name" of all groups and components nested in the component/group (inclusive of the current component/group).
=NestedAttributeCount("attribute_name", "attribute_dictionary"{optional})
- counts the instances of an attribute with "attribute_name" in nested components/groups.
For both functions, an optional "attribute_dictionary" argument is available for those users who wish to calculate values of attributes outside of the "dynamic_attributes" Attribute Dictionary.
You will not find these functions listed in the functions list at present; these must be typed in manually.
Installation
Install from the Plugin Store:
http://sketchucation.com/pluginstore?pln=DCFunctionNestedAttributes
As this plugin requires the Component Attributes feature, it will only work on Sketchup Pro. Sorry free users.
Tested on Sketchup 8, and 2014 Pro
Usage:
A classic use of this plugin would be to dynamically total prices for a set of components, or even for an entire project (as in image above).
Other uses would be to track total internal areas for costings, volume of concrete etc, all within the model without having to generate a report. These are simple tools which tie information about your project into the design workflow.
New in v0.3b
- New menu options added in Plugins > Attribute Formulas. "Dynamically Recalculate" switches on/of dynamic recalculation of nested attribute formulae. "Recalculate All Formulas" does what it says when "Dynamically Recalculate" option is turned off.
v0.4
- Compatability fix for Sketchup 2013 and 2014
Known Bugs
- Does not work well with newly opened models. To get formulas to calculate again when a model is opened, any attribute in the group/component with the formula in them must be edited again for the update process to be triggered.
- Unstable with larger models.
- Performance issues for very large models with many levels of nested groups/components.
Note to developers
This is my first successful attempt at a ruby plugin. Although I have tried to follow the advice given here in the forums and elsewhere, I could probably do with a code review from someone more experienced.
Future development goals:
- Improve performance and stability.
- Add the function to the list of available functions in DC
Thanks to:
- Dan and his rigourous documenting of good practices in Ruby coding (I hope I followed them well enough!)
- TIG for elaborating on the potential of dynamic functions in this post: http://sketchucation.com/forums/viewtopic.php?f=180%26amp;t=37083|/viewtopic.php?f=180%26amp;t=37083
- Whoever made this useful document on dynamic attributes: http://wiki.cfcl.com/bin/view/SketchUp/Cookbook/DA
I welcome all comments! This module needs improvement