SpaceDesign Calculations are used to preset or calculate vales for attributes.
- Set an attribute equal to a standard size - e.g. the X-width of a component.
e.g: %w% - (See Substitutions below)
- Set an attribute to a constant value - to be used in other calculations or for display.
e.g. 3.14159, or: File.basename(Sketchup.active_model.path))
- Calculate an attribute based on the value of other attributes.
e.g. %length% * %cost_per_foot% / 12.0
In the fields marked for substitution (Substitutions = y), you can enter values which will be replaced by the size of the component. This is done by using special codes, such as %w% in the description.
- %w% is replaced by the width of the component,
- %d% is replaced by the depth of the component,
- %h% is replaced by the height of the component
- %z% is replaced by the minimum z-height of the component
- %a% is replaced the area of a face in thc component. See: Area .
- %v% is replaced the volume for closed solids or by the product of width, depth and height for objects which are not closed solids.
- %n% is replaced by the name of the instance or component
%w%, %d% and %h% return values in inches even if you are using a different unit for your model.
- %w-m% will return a value in meters, %w-cm% in centimeters, and $w-f% in feet.
- Use %d-m%, %d-cm% and %d-f% for depth.
- Use %h-m%, %h-cm% and %h-f% for height.
- %v-m% will calculate the volume in cubic meters, %v-cm% will calculate the volume in cubic centimeters, and %v-f% will calculate the volume in cubic feet.
- %v-m% is the same as %v%/61023.744095. (We use the SketchUp calculation VOLUME/(1.0m * 1.0m * 1.0m) to convert from cubic inches to cubic meters.)
- %a-m% will calculate the area in square meters, %a-cm% will calculate the area in square centimeters, and %v-f% will calculate the area in square feet. We use the area of a face in the component. See: Area
Note: The string which receives the substitutions is the value stored on the component.
This lets you use a generic description for several components, which will be modified by the actual size of the component.
e.g.: "%w% x %d% table" will appear on reports as: 36" x 48 1/2" table
For width, depth, or height substitutions, you can also add an amount, in inches, which you would like to add or subtract from the actual size. e.g. %w" - 3.0 will subtract 3" from the width.
You can use %w% or other values to set or calculate a numeric.
- %w% - will be replaced by the width of the component
- %w% - 3.0 wil be replace by the width less 3.0"
Fields may be calculates based on values in other fields.
- Use %field% to represent the value from another field.
Calculations are executed using Ruby's eval() command. You may use any phrases which are available in Ruby.
- Floating point numbers must be preceded by a 0. For example, if you want to calculate a 17.5% tax, use a calculation like: %Base Price% * 0.175
There is a "Test" button for calculations on the edit attribute definition wizard.
The output shows the substitutions it makes to perform the calculation, the final ruby command, and the value after using it.
The '0's on each line are a level - for instance if a calculations uses another calculated field, it will show how that field is calculated as well.
If you select a component or group, before loading the attribute editor, it will perform the calculations on that item. Otherwise it uses the first component or group found in the model.
Ruby has a format, using ? and : to base a calculation on whether an expression is true of false.
- %length% > 180 ? 0.35 : 0.25
A conditional expression returns the value of either the expression before or the expression after the colon, depending on whether the logical expression before the question mark evaluates to true or false. In this case, if the length is greater than three, the expression returns 0.35. For shorter items, it returns 0.25.
If the calculation string starts with "DEF:", then the value will only be applied the first time, or if the current value is blank. Examples:
- DEF:Enter Description - will cause the value Enter Description tp be placed in the field if not other values has been entered.
- DEF:%n% - will cause the component name to be entered into the field if not other values has been entered.
Extended prices and costs
To include extended prices or costs in your report:
- Add an additional field, e.g. 'Extended Cost.
- Set the new field to total
- Set the original cost field not to total.
- Define extend_from for the extended cost field.
Extending length values
- Define a field equal to the length, e.g. length with the substitution value %w%
- Define a second field, to extend by length, e.g. cost_per_foot
- Define a third field, to be the extended cost, e.g. cost, with the calculation value: %length% * %cost_per_foot%
You can also do this without creating the length attribute if you donot need to show it:
- Define a field, to extend by length, e.g. cost_per_foot
- Define a second field, to be the extended cost, e.g. cost, with the calculation value: w% * %cost_per_foot%
- Calculations - setting attribute values based on size of components, or other attributes.
- Area - report on the area of a face in a component.
- Number Formatting - Database and Currency formatting
- List Attributes - creating a list of sub-attributes
- Filtering - filtering which attributes to include in report.
- Auto Generate Attributes - define and edit attributes in an excel spread sheet.