Skip to content

Commit 65ffbe0

Browse files
committed
Pyodide app readme
1 parent 936984d commit 65ffbe0

4 files changed

Lines changed: 65 additions & 0 deletions

File tree

src/pyodide/demo-app/README.md

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
# IfcOpenShell WASM
2+
3+
Live version: http://wasm.ifcopenshell.org
4+
5+
This is a technological preview of an IfcOpenShell WASM python module for use in [pyodide](https://pyodide.org/en/stable/). It uses [emscripten](https://emscripten.org/) to compile the C/C++ (of the python interpreter, IfcOpenShell and its dependencies respectively) into a WebAssembly (WASM) module. WebAssembly can be used in the browser or other JavaScript runtimes such as NodeJS.
6+
7+
## Demo
8+
9+
#### Draw polygonal walls and place door and windows by using the tool panel on the left
10+
11+
![](polygonal_walls.png)
12+
13+
#### Open existing .ifc models and improve accessibility by adding doors
14+
15+
![](fzk_improved_accessibility.png)
16+
17+
#### Save .ifc models and import in any compatible tool
18+
19+
![](fzk_improved_accessibility_bimvision.png)
20+
21+
## FAQ
22+
23+
- *Is this some half-baked attempt to compete with Bonsai?*
24+
25+
By all means no. And, actually, it's the same code under the hood, namely the IfcOpenShell API calls such as `root.create_entity`, `geometry.add_wall_representation` and `geometry.add_window_representation`.
26+
27+
## Approach
28+
29+
This approach of supporting IFC within the browser is rather heavy as it depends on a python interpreter loading the wasm-compiled monolithic IfcOpenShell wheel on demand. But nevertheless, we see this as the most powerful approach of enabling IfcOpenShell in the browser.
30+
31+
Over time, Python code has surpassed C++ as the predominant language in IfcOpenShell and has become the defacto standard for the IfcOpenShell API. We wouldn't want browser-based usage to require duplicating this powerful set of APIs.
32+
33+
Wrapping the full IfcOpenShell-python module results in a feature rich module, that makes for example, IFC validation, visualization, but also **authoring** a breeze because any pre-existing pure python module can be leveraged.
34+
35+
## Technical usage
36+
37+
### Pyodide proxy objects
38+
39+
Allows direct usage of python objects in JavaScript code.
40+
41+
```js
42+
let ifcopenshell_geom = pyodide.pyimport('ifcopenshell.geom');
43+
let s = ifcopenshell_geom.settings();
44+
s.set('weld-vertices', false);
45+
```
46+
47+
### Python code evaluation by Pyodide
48+
49+
Allows running actual python code with the ability for JavaScript to easily reflect on global variables.
50+
51+
```js
52+
pyodide.runPython(`
53+
from context import Context
54+
import numpy as np
55+
modelObject = Context()`);
56+
```
57+
58+
### In-line python code using PyScript
59+
60+
Allows running inline python code in HTML script tags
61+
62+
## Limitations
63+
64+
- Performance of loading and running code is not optimal.
65+
- C++ exception handling in the IfcOpenShell dependencies seems to cause issues in WASM, because the OpenCASCADE failures do not inherit from `std::exception`
45.2 KB
Loading
220 KB
Loading
35.8 KB
Loading

0 commit comments

Comments
 (0)