MCPcopy Create free account
hub / github.com/IfcOpenShell/IfcOpenShell / runAudit

Function runAudit

src/ifctester/webapp/src/modules/api/api.svelte.ts:292–339  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

290}
291
292export async function runAudit() {
293 if (IFCModels.models.length === 0) {
294 throw new Error('Please load an IFC model first');
295 }
296
297 if (!IDS.Module.activeDocument) {
298 throw new Error('Please create or open an IDS document first');
299 }
300
301 // Clear previous audit reports
302 IFCModels.audits = [];
303
304 // Get the active IDS document XML
305 const idsXml = await IDS.exportActiveDocument();
306 if (!idsXml) {
307 throw new Error('Failed to export IDS document');
308 }
309
310 // Run audit on all loaded models
311 let firstAuditReport: AuditReport | undefined;
312 for (const model of IFCModels.models) {
313 const result = await auditIfc(model.id, idsXml);
314
315 // Extract JSON and HTML reports from the result
316 const jsonData = result.json || null;
317 const htmlReport = result.html || null;
318
319 if (!jsonData) {
320 continue;
321 }
322 const auditReport = createAuditReport(model.id, IDS.Module.activeDocument as string, jsonData, htmlReport);
323
324 // Store the first audit report to open in viewer
325 if (!firstAuditReport) {
326 firstAuditReport = auditReport;
327 }
328 }
329
330 // Switch to viewer mode and set the first audit report as active
331 if (firstAuditReport && IDS.Module.activeDocument) {
332 IDS.setDocumentState(IDS.Module.activeDocument, {
333 viewMode: 'viewer',
334 auditReport: firstAuditReport.id
335 });
336 }
337
338 return firstAuditReport;
339}

Callers

nothing calls this directly

Calls 2

createAuditReportFunction · 0.85
auditIfcFunction · 0.70

Tested by

no test coverage detected