Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .github/workflows/translations.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,7 @@ jobs:
run: node translations/tools/reqfile_parity.js && node translations/tools/reqfile_parity.js --no-function-column
- name: Compliance page shows any plan with no custom code
run: node compliance/test/test_page.js
- name: Model page drills to one element with any results file
run: node compliance/test/test_model.js
- name: Dictionary, glossary and coverage
run: python3 translations/check_i18n.py --app --strict
32 changes: 32 additions & 0 deletions compliance/FORMAT.md
Original file line number Diff line number Diff line change
Expand Up @@ -154,3 +154,35 @@ from a real project without someone filling the gaps by hand:

Items 1 to 4 are an addition to the requirement file (Builder). Items 5 and 6 are an addition to the result
file (checker). With both, a small script turns a folder of results into this series, with no judgment calls.

## Element results: `openbep-compliance-elements` 0.1 (draft)

The page `/compliance/model/` shows where in one model version the plan is not followed, down to the single element and the single required value, and colours the model in 3D. It reads one file and has no project-specific code.

```
format "openbep-compliance-elements"
formatVersion "0.1"
example, note optional: true and a sentence when the file is an example
project.name
model name, url (https link to a .vim file, optional), format "vim", sizeMB, workshared
version label, date
checks[] 1 to 30. id, label, icon, help, parameter (the Revit parameter name),
on: "type" | "instance" | "element" (where the value is fixed)
columns always ["id","model","workset","category","family","type","level","required","filled"]
strings[] every name used once
elements[] one row per element, in the order of columns:
id the Revit element id
model to level positions in strings ("" means none)
required bit i is 1 when check i asks something of this element
filled bit i is 1 when that value is filled (never 1 where required is 0)
```

Rules the page applies, the same for every file:

- Compliance of any group is filled bits over required bits.
- An element is green when every required value is filled, yellow at half or more, red below half, grey when nothing is required of it by the check being looked at. The lists and the 3D view use the same four colours.
- Levels: model, workset, category, family, type, element, required value. Or level (storey) first. A level with a single group is passed through.
- For a check fixed on the type, the page counts the types to fill and the elements that fixes.
- Without `model.url` the lists still work; there is no 3D view.

The 3D view is VIM's open web viewer (github.com/vimaec/vim-web, MIT), loaded from a public CDN only when the model is shown. The example file is built once by `compliance/model/tools/build_residence.js` from real values in VIM's public sample model. Open gaps: a real file needs VIM Server (or another checker) to export one row per element, which the result file 1.1 does not carry yet. One file is one version; change over time per element is not in the format yet.
1 change: 1 addition & 0 deletions compliance/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -347,6 +347,7 @@
<ul class="rules"><li>A claim is valid under the plan when the firm meets all four conditions. The contract decides payment: these conditions count only where the contract makes them part of a valid payment claim.</li></ul>
</section>

<p class="example" data-lv="1" style="border-left-color:var(--accent);background:var(--accent-soft)"><b>Next level down: where in the model.</b> <a href="model/">Open a model in 3D, coloured by compliance</a>, and go from the model to the category, family, type and single element. The example there is a different building: VIM's public sample house, with real values.</p>
<details id="dig" class="keep" data-lv="1 2"><summary>Show more detail: pace by firm, each goal, what changed since another version, every check by version</summary>
<section aria-labelledby="h-pace">
<div class="sh"><h2 id="h-pace">Who contributes at what pace</h2><span class="note">Each firm's own elements. Pace is counted over the last four working weeks; holiday weeks are not counted.</span></div>
Expand Down
3,342 changes: 3,342 additions & 0 deletions compliance/model/example-residence.json

Large diffs are not rendered by default.

334 changes: 334 additions & 0 deletions compliance/model/index.html

Large diffs are not rendered by default.

51 changes: 51 additions & 0 deletions compliance/model/tools/build_residence.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
<!doctype html><meta charset="utf-8"><title>Build the element results for VIM's sample house</title><body>
<!-- One-off tool, not part of the site. Run with build_residence.js. It reads real parameter values
from VIM's public sample model and writes them in the openbep-compliance-elements format. -->
<div id="v" style="width:800px;height:500px;position:relative"></div>
<script src="https://cdnjs.cloudflare.com/ajax/libs/react/18.3.1/umd/react.production.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/react-dom/18.3.1/umd/react-dom.production.min.js"></script>
<script>window.process=window.process||{env:{NODE_ENV:'production'}};React.jsx=React.jsxs=(t,p,k)=>React.createElement(t,k===undefined?p:Object.assign({},p,{key:k}))</script>
<script src="https://cdn.jsdelivr.net/npm/vim-web@1.0.0-beta.2/dist/vim-web.iife.js"></script>
<script>
const URL_='https://storage.cdn.vimaec.com/samples/residence.v1.2.75.vim';
// The example's checks. Each names one Revit parameter, where it lives, and the categories it is required on.
const CHECKS=[
{id:'assembly-code',label:'Assembly Code filled',icon:'code',param:'Assembly Code',on:'type',cats:null,help:'Every element needs its cost code so quantities can be priced.'},
{id:'fire-rating',label:'Fire rating on walls, doors and floors',icon:'fire',param:'Fire Rating',on:'type',cats:['Walls','Doors','Floors'],help:'Walls, doors and floors must carry their fire rating so the other trades can coordinate with them.'},
{id:'mark',label:'Mark on doors, windows, fixtures and equipment',icon:'duplicate',param:'Mark',on:'instance',cats:['Doors','Windows','Plumbing Fixtures','Mechanical Equipment','Electrical Equipment','Electrical Fixtures','Lighting Fixtures','Specialty Equipment'],help:'Each door, window and piece of equipment needs its own number so it can be found on site and at handover.'},
{id:'type-mark',label:'Type Mark on doors and windows',icon:'name',param:'Type Mark',on:'type',cats:['Doors','Windows'],help:'The type mark ties each door and window to its line in the schedule.'},
{id:'manufacturer',label:'Manufacturer on fixtures and equipment',icon:'asset',param:'Manufacturer',on:'type',cats:['Plumbing Fixtures','Mechanical Equipment','Electrical Equipment','Electrical Fixtures','Lighting Fixtures','Specialty Equipment','Doors','Windows'],help:'The owner needs to know who made each product to maintain or replace it.'},
{id:'level',label:'Element tied to a level',icon:'level',param:null,on:'element',cats:null,help:'An element that is not tied to a level cannot be counted by floor.'},
];
(async()=>{try{
const VIM=window.VIMReact;const viewer=await VIM.React.Webgl.createViewer(document.getElementById('v'),{});
const vim=await viewer.load({url:new URLSearchParams(location.search).get('vim')||URL_}).getVim();
const b=vim.bim,els=vim.getAllElements();
const [E,C,W,L,PD,P,D,FI,FT]=await Promise.all([b.element.getAll(),b.category.getAll(),b.workset.getAll(),b.level.getAll(),b.parameterDescriptor.getAll(),b.parameter.getAll(),b.bimDocument.getAll(),b.familyInstance.getAll(),b.familyType.getAll()]);
const mesh=new Set(els.filter(e=>e.hasMesh).map(e=>e.element));
const names=new Set(CHECKS.map(c=>c.param).filter(Boolean)),val={}; // val[param][elementIndex]=value
for(const p of P){const n=PD[p.parameterDescriptorIndex]&&PD[p.parameterDescriptorIndex].name;if(!names.has(n)) continue;(val[n]||(val[n]={}))[p.elementIndex]=p.value||''}
const filled=v=>{if(v==null) return null;const s=String(v).split('|');const t=(s.length>1?s[s.length-1]:s[0]).trim();return !!t&&t!=='<None>'&&t!=='<By Category>'};
const typeEl={};for(const fi of FI){const ft=FT[fi.familyTypeIndex];if(ft&&ft.elementIndex>=0) typeEl[fi.elementIndex]=ft.elementIndex}
const byKey={};for(const ft of FT){const e=E[ft.elementIndex];if(e) byKey[e.categoryIndex+'|'+e.familyName+'|'+e.name]=e.index}
const lvlName=i=>i>=0&&L[i]&&E[L[i].elementIndex]?E[L[i].elementIndex].name:'';
const S=[],si={},sx=s=>{s=s||'';if(!(s in si)){si[s]=S.length;S.push(s)}return si[s]};
const rows=[];let noType=0;
for(const e of E){if(!mesh.has(e.index)) continue;const c=C[e.categoryIndex];if(!c||c.categoryType!=='Model') continue;
let t=typeEl[e.index];if(t==null) t=byKey[e.categoryIndex+'|'+e.familyName+'|'+e.type];if(t==null) noType++;
let req=0,met=0;CHECKS.forEach((k,i)=>{if(k.cats&&!k.cats.includes(c.name)) return;let f;
if(k.on==='element') f=e.levelIndex>=0;else{const src=k.on==='type'?t:e.index;f=src==null?null:filled((val[k.param]||{})[src]);if(f===null) return} // parameter absent: not required here
req|=1<<i;if(f) met|=1<<i});
if(!req) continue;
const w=W[e.worksetIndex];
rows.push([Number(e.id),sx(D[e.bimDocumentIndex]?D[e.bimDocumentIndex].title:''),sx(w&&w.kind==='UserWorkset'?w.name:''),sx(c.name),sx(e.familyName),sx(e.type),sx(lvlName(e.levelIndex)),req,met])}
rows.sort((a,b)=>a[0]-b[0]);
window.out={format:'openbep-compliance-elements',formatVersion:'0.1',example:true,
note:"Real values, read once from VIM's public sample model by compliance/model/tools/build_residence.js. No VIM Server checked this model; the checks are examples.",
project:{name:'Example: sample house (Wolford Residence)'},
model:{name:D[0]?D[0].title:'',url:URL_,format:'vim',sizeMB:37,workshared:!!(D[0]&&D[0].isWorkshared)},
version:{label:'Sample file',date:'2023-08-28'},
checks:CHECKS.map(({id,label,icon,param,on,help})=>({id,label,icon,parameter:param,on,help})),
columns:['id','model','workset','category','family','type','level','required','filled'],strings:S,elements:rows};
window.stats={elements:E.length,withMesh:mesh.size,rows:rows.length,noType};window.done=true}catch(x){window.err=String(x&&x.stack||x);window.done=true}})()
</script>
16 changes: 16 additions & 0 deletions compliance/model/tools/build_residence.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

60 changes: 60 additions & 0 deletions compliance/test/test_model.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
// The model page: drill from the whole model to one element with any results file, numbers add up,
// a link reopens the same place, and a broken file is refused. The 3D viewer is not loaded here.
// Usage: node compliance/test/test_model.js (needs Playwright + Chromium)
const { chromium } = require('playwright');
const http = require('node:http'), fs = require('node:fs'), path = require('node:path');
const root = path.resolve(__dirname, '..', '..');
const ex = JSON.parse(fs.readFileSync(path.join(root, 'compliance/model/example-residence.json'), 'utf8'));
// A second, very different file: two models, real worksets, three checks.
const other = {
format: 'openbep-compliance-elements', formatVersion: '0.1', project: { name: 'Other' }, model: { name: 'Two models' }, version: { label: 'V1' },
checks: [{ id: 'a', label: 'Check A', parameter: 'A', on: 'type' }, { id: 'b', label: 'Check B', parameter: 'B', on: 'instance' }, { id: 'c', label: 'Check C', on: 'element' }],
columns: ex.columns, strings: ['', 'M1', 'M2', 'Shell', 'Interior', 'Walls', 'Doors', 'Fam', 'T1', 'T2', 'L1'],
elements: Array.from({ length: 40 }, (_, i) => [1000 + i, 1 + i % 2, 3 + (i >> 1) % 2, 5 + (i >> 2) % 2, 7, 8 + (i >> 3) % 2, 10, 7, i % 8]),
};
const broken = Object.assign({}, other, { elements: [[1, 1, 3, 5, 7, 8, 10, 1, 3]] });
const files = { '/compliance/model/other.json': other, '/compliance/model/broken.json': broken };
const pop = x => { let n = 0; while (x) { n += x & 1; x >>>= 1; } return n; };

const srv = http.createServer((q, r) => {
const u = decodeURIComponent(q.url.split('?')[0]);
if (files[u]) return r.end(JSON.stringify(files[u]));
let f = path.join(root, u); if (u.endsWith('/')) f += 'index.html';
fs.readFile(f, (e, d) => {
if (e) { r.writeHead(404); r.end(); return; }
r.writeHead(200, { 'content-type': f.endsWith('.html') ? 'text/html' : 'application/json' }); r.end(d);
});
});
srv.listen(0, async () => {
const base = 'http://localhost:' + srv.address().port + '/compliance/model/';
const b = await chromium.launch(); let failed = 0;
const ok = (n, c) => { console.log((c ? 'ok ' : 'FAIL ') + n); if (!c) failed++; };
for (const [name, file, d] of [['example', '', ex], ['other', 'other.json', other]]) for (const w of [1280, 390]) {
const p = await b.newPage({ viewport: { width: w, height: 800 } }); const errs = []; p.on('pageerror', e => errs.push(e.message));
await p.route(/^https:/, r => r.abort());
const q = file ? '&file=' + file : '';
await p.goto(base + '?no3d=1' + q); await p.waitForSelector('#rows .row');
const req = d.elements.reduce((s, r) => s + pop(r[7]), 0), met = d.elements.reduce((s, r) => s + pop(r[8]), 0);
const want = (Math.floor(1000 * met / req) / 10).toFixed(1) + ' %';
ok(name + ' ' + w + ': verdict shows ' + want, (await p.textContent('#verdict .gt')).startsWith(want));
const counts = await p.$$eval('#rows .row .sm', a => a.map(x => parseInt(x.textContent.replace(/,/g, ''), 10)));
ok(name + ' ' + w + ': first level adds up to every element', counts.reduce((s, n) => s + n, 0) === d.elements.length);
let guard = 0;
while (await p.$('#rows .row[data-into]') && guard++ < 8) await p.click('#rows .row[data-into]');
ok(name + ' ' + w + ': drill reaches single elements', !!(await p.$('#rows .row[data-el]')));
await p.click('#rows .row[data-el]'); await p.waitForSelector('.el table');
ok(name + ' ' + w + ': element shows one line per check', (await p.$$('.el tbody tr')).length === d.checks.length);
ok(name + ' ' + w + ': fits the screen', await p.evaluate(() => document.documentElement.scrollWidth <= innerWidth));
const u = p.url(); await p.goto(u); await p.waitForSelector('.el table');
ok(name + ' ' + w + ': link reopens the element', /el=\d+/.test(u));
await p.goto(base + '?no3d=1&check=' + d.checks[0].id + q); await p.waitForSelector('#rows .row');
ok(name + ' ' + w + ': check filter is on', !!(await p.$('.chk.on')));
ok(name + ' ' + w + ': no script errors', !errs.length); if (errs.length) console.log(errs);
await p.close();
}
const p = await b.newPage(); await p.goto(base + '?file=broken.json'); await p.waitForSelector('.err');
ok('broken file is refused with a reason', /not a valid row/.test(await p.textContent('.err')));
await b.close(); srv.close();
if (failed) { console.log(failed + ' failed'); process.exit(1); }
console.log('all model page checks passed');
});
Loading