Writes floor elevations and heights, room heights and areas, warranty durations and expected life into the COBie workbook, and reads service life and warranty back from one.
How the precision is kept
Lengths and areas are the file's own values, rounded to three decimals when written to the sheet. When the file's length unit is the millimeter, centimeter, meter, inch or foot the values are written in that unit and the Facility sheet names it; any other unit is converted to millimeters. Durations in years are rounded to one decimal.
Calculations under this policy
6 calculations in 1 source file. The code is read from the released app when this page loads. It is the calculation people run, not a copy kept for this page.
A value rounded to three decimals (or another count) for the workbook.
round(x, d) = Math.round(x × 10ᵈ) ÷ 10ᵈ
The value is multiplied by a power of ten in 64-bit before it is rounded, so a decimal half can fall just below the half: round(0.5005, 3) gives 0.5, because 0.5005 × 1000 is 500.49999999999994.
Floor elevation and height, room height and room areas as the workbook holds them.
length = round(x × k, 3); area = round(x × k², 3)
k is 1 when the file's unit is one of the five named units, otherwise the millimeters per file unit. The value kept in the workbook is rounded to three decimals of that unit. Areas use k × k.
assets-bim-cobie.js
lines 138 to 139
BimCraft 0.8.1
const num = (x, d = 3) => (Number.isFinite(x) ? round(x * facts.k, d) : null); // file units → the Facility's unit
const area = (x) => (Number.isFinite(x) ? round(x * facts.k * facts.k, 3) : null);
Floor height
64-bit
The height of each floor, from its elevation to the next floor's.
height = elevationₙ₊₁ − elevationₙ
One 64-bit subtraction of two elevations read from the file, in file units, after the floors are sorted by elevation. The top floor has no height.
The length of a warranty from its start and end dates.
years = (end − start) ÷ (365.25 × 86400000 ms), rounded to 0.1
Both dates are parsed as UTC days, so the difference is a whole number of days. The result is rounded to one decimal of a year and is null when it is not above zero.
assets-bim-cobie.js
lines 119 to 120
BimCraft 0.8.1
// ---------------------------------------------------------------- out
const yearsBetween = (a, b) => { if (!isDay(a) || !isDay(b)) return null; const y = (Date.parse(b) - Date.parse(a)) / (365.25 * 86400000); return y > 0 ? Math.round(y * 10) / 10 : null; };
Expected life read from a workbook
64-bit
A type's expected life in years, from a value in years, months, weeks or days.
years = months ÷ 12, weeks ÷ 52.1775, days ÷ 365.25; rounded to 0.1
The cell must be a plain decimal number. The result is rounded to one decimal of a year and kept only when it is above 0 and at most 200.
assets-bim-cobie.js
lines 215 to 221
BimCraft 0.8.1
const lifeOf = (v, unit) => {
const s = blank(v);
if (!s || !/^\d+(\.\d+)?$/.test(s)) return '';
const u = String(unit || '').toLowerCase(), x = Number(s);
const y = /month/.test(u) ? x / 12 : /week/.test(u) ? x / 52.1775 : /day/.test(u) ? x / 365.25 : x;
return y > 0 && y <= 200 ? String(Math.round(y * 10) / 10) : '';
};
Warranty end date from its duration
64-bit
The day a warranty ends, when the workbook gives only its start and its length in years.
end = start + round(years × 12) months
The duration is turned into a whole number of months with Math.round and added to the start date with setUTCMonth. A start day the end month does not have rolls over into the following month, as JavaScript dates do.
Floor height = the next floor's elevation − this floor's. Warranty years = days between the two dates ÷ 365.25. Expected life on import: months ÷ 12, weeks ÷ 52.1775, days ÷ 365.25.
Number types
64-bit numbers; dates as milliseconds since 1970 (UTC).
Limits
Three decimals of the sheet's unit: 0.001 mm in a millimeter file, 1 mm in a meter file. Areas are scaled with the square of the length factor; the file's own area unit is not read. The week divisor corresponds to a 365.2425-day year and the day divisor to a 365.25-day year.
Approach: 64-bit, direct
Every value is a 64-bit number from input to result. Formulas are closed form or a direct solve, and every comparison uses a stated tolerance.