docs: document bcf_viewpoint_to_ifc_url() and IfcUrl.to_string()

Update SPECIFICATION.md §6 to clarify the isolate-visibility mapping
(DefaultVisibility=false + Exceptions). Add library usage examples to
README for to_string() and bcf_viewpoint_to_ifc_url().

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Bruno Postle 2026-04-29 19:07:53 +01:00
parent 2de4af5f4d
commit 427a0e6d74
2 changed files with 25 additions and 2 deletions

View file

@ -234,6 +234,27 @@ png = render(model, selector=url.selector, clips=url.clips or None,
camera=url.camera, fov=url.fov, visibility=url.visibility) camera=url.camera, fov=url.fov, visibility=url.visibility)
``` ```
Serialise a parsed URL back to a string with `.to_string()`:
```python
url = IfcUrl.parse("ifc://example.com/org/repo@heads/main?path=model.ifc")
modified = dataclasses.replace(url, selector="IfcWall", visibility="ghost")
print(modified.to_string())
# ifc://example.com/org/repo@heads/main?path=model.ifc&selector=IfcWall&visibility=ghost
```
Convert a BCF 3.0 REST viewpoint dict to an `ifc://` URL (§6 reverse direction):
```python
from ifcurl.bcf import bcf_viewpoint_to_ifc_url
base = IfcUrl.parse("ifc://example.com/org/repo@heads/main?path=model.ifc")
ifc_url = bcf_viewpoint_to_ifc_url(base, viewpoint_dict)
```
`viewpoint_dict` is a BCF 3.0 REST API viewpoint object (camera, clipping planes,
component selection/visibility). The repo/ref/path context comes from `base`.
Remote repositories are cloned as bare repos to the OS cache directory (`~/.cache/ifcurl/` on Linux) on first use. Mutable refs (`@heads/`, `@HEAD`) trigger a `git fetch`; immutable refs (commit hashes, tags) use the cache as-is. Remote repositories are cloned as bare repos to the OS cache directory (`~/.cache/ifcurl/` on Linux) on first use. Mutable refs (`@heads/`, `@HEAD`) trigger a `git fetch`; immutable refs (commit hashes, tags) use the cache as-is.
For private repositories, configure tokens per host in `~/.config/ifcurl/tokens.json`: For private repositories, configure tokens per host in `~/.config/ifcurl/tokens.json`:

View file

@ -251,8 +251,10 @@ The camera and selection in an IFC URL map directly to BCF viewpoint concepts.
4. Populate `Components/Selection` with the resolved GUIDs 4. Populate `Components/Selection` with the resolved GUIDs
**BCF viewpoint to IFC URL:** **BCF viewpoint to IFC URL:**
1. Extract the GUID list from `Components/Selection` 1. Extract the GUID list from `Components/Selection`; if `DefaultVisibility`
2. Construct an IfcOpenShell GUID selector is false, use the GUIDs from `Visibility/Exceptions` instead and set
`visibility=isolate`
2. Construct an IfcOpenShell GUID selector (bare GUIDs joined with `+`)
3. Convert the BCF camera to `camera`, `fov` or `scale` parameters 3. Convert the BCF camera to `camera`, `fov` or `scale` parameters
4. Convert clipping planes to `clip` parameters 4. Convert clipping planes to `clip` parameters