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

Function openIfc

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

Source from the content-addressed store, hash-verified

190}
191
192export async function openIfc() {
193 return new Promise<void>((resolve, reject) => {
194 const fileInput = document.createElement('input');
195 fileInput.type = 'file';
196 fileInput.accept = '.ifc';
197
198 fileInput.onchange = async (event) => {
199 const target = event.target as HTMLInputElement | null;
200 const file = target?.files?.[0];
201 if (!file) {
202 reject(new Error('No file selected'));
203 return;
204 }
205
206 // Check if it's an IFC file
207 if (!file.name.toLowerCase().endsWith('.ifc')) {
208 reject(new Error('Please select a valid IFC file (.ifc)'));
209 return;
210 }
211
212 try {
213 await loadIfc(file);
214 resolve();
215 } catch (error) {
216 reject(error);
217 }
218 };
219
220 fileInput.onerror = () => reject(new Error('Failed to open file picker'));
221 fileInput.click();
222 });
223}
224
225export function getIfcById(modelId: string) {
226 return IFCModels.models.find(model => model.id === modelId);

Callers

nothing calls this directly

Calls 1

loadIfcFunction · 0.70

Tested by

no test coverage detected