mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-10 17:58:20 +00:00
README and pyproject.toml fixes for ifcquery, ifcedit, ifcmcp
This commit is contained in:
@@ -237,7 +237,7 @@ Exit code is 0 on success, 1 on error.
|
||||
|
||||
`ifcedit` and `ifcquery` are complementary tools:
|
||||
|
||||
- **ifcquery** reads and inspects IFC models (summary, tree, info, select, relations, clash, validate, schedule, cost, schema)
|
||||
- **ifcquery** reads and inspects IFC models (summary, tree, info, select, relations, clash, validate, schedule, cost, schema, contexts, materials, plot, render)
|
||||
- **ifcedit** modifies IFC models by wrapping `ifcopenshell.api` functions, and runs QTO via `quantify`
|
||||
|
||||
A typical workflow: inspect with `ifcquery`, look up the right API function
|
||||
|
||||
+108
-1
@@ -11,7 +11,7 @@ sessions.
|
||||
pip install ifcmcp
|
||||
```
|
||||
|
||||
Requires `ifcopenshell`, `ifcquery`, `ifcedit`, and `mcp`.
|
||||
Requires `ifcopenshell`, `ifcquery`, and `ifcedit`. The `mcp` package is an optional dependency needed to run the server; install it with `pip install ifcmcp[mcp]` or add `mcp` separately.
|
||||
|
||||
## Running the server
|
||||
|
||||
@@ -55,6 +55,17 @@ load model.ifc using ifc_load
|
||||
|
||||
### Session
|
||||
|
||||
#### ifc_new
|
||||
|
||||
Create a new empty IFC model in memory, replacing any currently loaded model.
|
||||
|
||||
```
|
||||
ifc_new()
|
||||
ifc_new(schema="IFC4X3")
|
||||
```
|
||||
|
||||
Default schema is `IFC4`.
|
||||
|
||||
#### ifc_load
|
||||
|
||||
Open an IFC file into memory.
|
||||
@@ -64,6 +75,14 @@ ifc_load(path="/path/to/model.ifc")
|
||||
-> "Loaded /path/to/model.ifc: schema IFC4, 1847 entities"
|
||||
```
|
||||
|
||||
#### ifc_reset
|
||||
|
||||
Unload the current model from memory, freeing all session state.
|
||||
|
||||
```
|
||||
ifc_reset()
|
||||
```
|
||||
|
||||
#### ifc_save
|
||||
|
||||
Write the in-memory model to disk. Empty path overwrites the original file.
|
||||
@@ -142,6 +161,22 @@ ifc_relations(element_id=10, traverse="up")
|
||||
|
||||
With `traverse="up"`, walks the hierarchy from element up to IfcProject.
|
||||
|
||||
#### ifc_contexts
|
||||
|
||||
List all geometric representation contexts and subcontexts in the loaded model.
|
||||
|
||||
```
|
||||
ifc_contexts()
|
||||
```
|
||||
|
||||
#### ifc_materials
|
||||
|
||||
List all materials and material sets in the loaded model, with their assigned elements.
|
||||
|
||||
```
|
||||
ifc_materials()
|
||||
```
|
||||
|
||||
#### ifc_clash
|
||||
|
||||
Check an element for geometric intersections and clearance violations.
|
||||
@@ -225,6 +260,78 @@ are quantified (default: all `IfcElement`).
|
||||
|
||||
Returns `{"ok": true, "rule": "...", "elements_quantified": 42}`.
|
||||
|
||||
### Drawing and rendering tools
|
||||
|
||||
#### ifc_plot
|
||||
|
||||
Generate a 2D technical drawing of the loaded model and return it as an inline image.
|
||||
|
||||
```
|
||||
ifc_plot()
|
||||
ifc_plot(selector="IfcWall", view="floorplan", scale=0.01, output_path="/tmp/plan.svg")
|
||||
ifc_plot(element_ids=[10, 11], view="floorplan")
|
||||
```
|
||||
|
||||
Parameters:
|
||||
|
||||
- `selector` -- ifcopenshell selector to restrict plotted elements
|
||||
- `element_ids` -- step IDs of elements to highlight; others are faded
|
||||
- `view` -- `"floorplan"` (default), `"elevation"`, `"section"`, or `"auto"`
|
||||
- `width_mm`, `height_mm` -- paper size in mm (default: 297 x 420)
|
||||
- `scale` -- model-to-paper ratio (default: 0.01 = 1:100)
|
||||
- `png_width`, `png_height` -- raster output size in pixels (default: 1024 x 1024)
|
||||
- `output_path` -- optional path to also save to disk (`.svg` for vector, otherwise PNG)
|
||||
|
||||
Returns an inline PNG the LLM can inspect. Requires `ifcopenshell.draw`.
|
||||
|
||||
#### ifc_render
|
||||
|
||||
Render the loaded model to a 3D PNG image.
|
||||
|
||||
```
|
||||
ifc_render()
|
||||
ifc_render(selector="IfcWall", view="iso", output_path="/tmp/model.png")
|
||||
ifc_render(element_ids=[10, 11], view="south")
|
||||
```
|
||||
|
||||
Parameters:
|
||||
|
||||
- `selector` -- ifcopenshell selector to restrict rendered elements
|
||||
- `element_ids` -- step IDs of elements to highlight; others are shown translucent
|
||||
- `view` -- `"iso"` (default), `"top"`, `"south"`, `"north"`, `"east"`, or `"west"`
|
||||
- `output_path` -- optional path to save the PNG to disk
|
||||
|
||||
Returns an inline PNG. Requires `pyvista` and the IfcOpenShell C++ geometry bindings.
|
||||
|
||||
### Shape builder tools
|
||||
|
||||
#### ifc_shape_list
|
||||
|
||||
List all available `ShapeBuilder` methods with brief descriptions.
|
||||
|
||||
```
|
||||
ifc_shape_list()
|
||||
```
|
||||
|
||||
#### ifc_shape_docs
|
||||
|
||||
Show full documentation for a specific `ShapeBuilder` method.
|
||||
|
||||
```
|
||||
ifc_shape_docs(method="extrude")
|
||||
ifc_shape_docs(method="create_ellipse")
|
||||
```
|
||||
|
||||
#### ifc_shape
|
||||
|
||||
Execute a `ShapeBuilder` method on the loaded model.
|
||||
|
||||
```
|
||||
ifc_shape(method="extrude", params='{"profile": "42", "magnitude": 3.0}')
|
||||
```
|
||||
|
||||
`params` is a JSON string; entity references are resolved by step ID (same coercion as `ifc_edit`).
|
||||
|
||||
### Edit discovery tools
|
||||
|
||||
#### ifc_list
|
||||
|
||||
@@ -9,6 +9,7 @@ authors = [
|
||||
{ name="Bruno Postle", email="bruno@postle.net" },
|
||||
]
|
||||
description = "MCP server for querying and editing IFC building models"
|
||||
readme = "README.md"
|
||||
keywords = ["IFC", "BIM", "MCP"]
|
||||
classifiers = [
|
||||
"Programming Language :: Python :: 3",
|
||||
|
||||
@@ -324,6 +324,84 @@ ifcquery model.ifc schema IfcBuildingStorey
|
||||
|
||||
Returns `{"error": "Unknown entity: Foo"}` for unrecognised types.
|
||||
|
||||
### contexts
|
||||
|
||||
List all geometric representation contexts and subcontexts in the model.
|
||||
|
||||
```bash
|
||||
ifcquery model.ifc contexts
|
||||
```
|
||||
|
||||
```json
|
||||
[
|
||||
{
|
||||
"id": 5,
|
||||
"type": "IfcGeometricRepresentationContext",
|
||||
"context_type": "Model",
|
||||
"subcontexts": [
|
||||
{"id": 6, "type": "IfcGeometricRepresentationSubContext", "context_identifier": "Body", "target_view": "MODEL_VIEW"},
|
||||
{"id": 7, "type": "IfcGeometricRepresentationSubContext", "context_identifier": "Axis", "target_view": "GRAPH_VIEW"}
|
||||
]
|
||||
}
|
||||
]
|
||||
```
|
||||
|
||||
### materials
|
||||
|
||||
List all materials and material sets used in the model, with their assigned elements.
|
||||
|
||||
```bash
|
||||
ifcquery model.ifc materials
|
||||
```
|
||||
|
||||
```json
|
||||
[
|
||||
{
|
||||
"id": 60,
|
||||
"type": "IfcMaterial",
|
||||
"name": "Concrete",
|
||||
"elements": [{"id": 10, "type": "IfcWall", "name": "Wall001"}]
|
||||
}
|
||||
]
|
||||
```
|
||||
|
||||
### plot
|
||||
|
||||
Generate a 2D technical drawing (floor plan, elevation, or section) of the model and write it to a file.
|
||||
|
||||
```bash
|
||||
ifcquery model.ifc plot output.svg
|
||||
ifcquery model.ifc plot output.png --view floorplan --scale 0.01
|
||||
```
|
||||
|
||||
Options:
|
||||
|
||||
- `--view {floorplan,elevation,section,auto}` -- drawing view (default: `floorplan`)
|
||||
- `--scale <ratio>` -- model-to-paper scale ratio (default: 0.01 = 1:100)
|
||||
- `--width-mm <mm>` -- paper width in mm (default: 297)
|
||||
- `--height-mm <mm>` -- paper height in mm (default: 420)
|
||||
- `--png-width <px>` -- raster output width in pixels (default: 1024)
|
||||
- `--png-height <px>` -- raster output height in pixels (default: 1024)
|
||||
|
||||
Writes SVG when the output path ends in `.svg`, otherwise PNG.
|
||||
Requires the IfcOpenShell drawing module (`ifcopenshell.draw`).
|
||||
|
||||
### render
|
||||
|
||||
Render a 3D view of the model geometry to a PNG file.
|
||||
|
||||
```bash
|
||||
ifcquery model.ifc render output.png
|
||||
ifcquery model.ifc render output.png --view iso --selector IfcWall
|
||||
```
|
||||
|
||||
Options:
|
||||
|
||||
- `--view {iso,top,south,north,east,west}` -- camera angle (default: `iso`)
|
||||
- `--selector <query>` -- ifcopenshell selector to restrict rendered elements
|
||||
|
||||
Requires `pyvista` and the IfcOpenShell C++ geometry bindings.
|
||||
|
||||
### clash
|
||||
|
||||
Check a single element for geometric intersections and clearance violations
|
||||
|
||||
Reference in New Issue
Block a user