Metadata-Version: 2.3
Name: ifc-anywidget
Version: 0.5.0
Summary: IFC viewer AnyWidget using That Open Company Open BIM Components
Author: sanzoghenzo
License: Copyright (c) 2025 Andrea Ghensi
         
         Permission is hereby granted, free of charge, to any person
         obtaining a copy of this software and associated documentation
         files (the "Software"), to deal in the Software without
         restriction, including without limitation the rights to use,
         copy, modify, merge, publish, distribute, sublicense, and/or sell
         copies of the Software, and to permit persons to whom the
         Software is furnished to do so, subject to the following
         conditions:
         
         The above copyright notice and this permission notice shall be
         included in all copies or substantial portions of the Software.
         
         THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
         EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
         OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
         NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
         HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
         WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
         FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
         OTHER DEALINGS IN THE SOFTWARE.
Requires-Dist: anywidget>=0.11.0
Requires-Dist: ifcopenshell>=0.8.2
Requires-Python: >=3.10
Project-URL: Source, https://github.com/sanzoghenzo/ifc-viewer-anywidget
Description-Content-Type: text/markdown

# IFC viewer anywidget

Display an IFC model in your Jupyter/marimo notebook.

Uses [anywidget](https://anywidget.dev/) and [IFCLite](https://louistrue.github.io/ifc-lite/)

- Displays an `ifcopenshell.file` object using the IFCLite viewer
- returns the list of `GlobalId`s of the selected elements via `selected_guids` attribute 

![marimo example](marimo.png)

## install

If you're using marimo in sandbox mode, skip this part.
Marimo will detect the import and ask you to install the package.

If you're running JupyterLab, add the library to your environment:

```shell
pip install ifc-anywidget
```

if you're using uv (highly recommended), run

```shell
uv add ifc-anywidget
```

## usage

```
from ifc_anywidget import IfcViewer
import ifcopenshell

model = ifcopenshell.open("my-awesome-model.ifc")
viewer = IfcViewer(ifc_model=model) # for marimo: wrap it with mo.ui.anywidget()
viewer
```

`IfcVewer` supports the following attributes:

- `ifc_model`: the `ifcopenshell.file` instance to show
- `hide_sites`: whether to hide IfcSite elements (default: False)
- `hide_spaces`: whether to hide IfcSpace elements (default: True)
- `hide_spatial_zones`: whether to hide IfcSpatialZone elements (default: True)
- `hide_opening_elements`: whether to hide IfcOpeningElement elements (default: True)
- `hide_annotations`: whether to hide IfcAnnotation elements (default: True)
- `hide_grids`: whether to hide IfcGrid elements (default: True)

Using marimo, you can set these attributes reactively (for instance, with a toggle widget).  
Take a look at the `tests/test_marimo.py` notebook to see an example.

## development

Clone the repo and run `uv sync` to initialize the environment with all the needed dependencies.

For testing within marimo, just run

```shell
uv run marimo edit tests/test_marimo.py
```

For testing within jupyter lab, run

```shell
uv run jupyter lab tests/test_jupyter.ipynb
```
