Skip to content

Commit 002b7c5

Browse files
committed
ifcquery, ifcmcp: better bot selector syntax hints
1 parent e7db239 commit 002b7c5

File tree

2 files changed

+22
-3
lines changed

2 files changed

+22
-3
lines changed

src/ifcmcp/ifcmcp/core.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,12 @@ def ifc_info(self, element_id: int) -> dict[str, Any]:
278278
return info.info(model, element)
279279

280280
def ifc_select(self, query: str) -> list[dict[str, Any]]:
281-
"""Filter elements using ifcopenshell selector syntax (e.g. 'IfcWall', 'IfcWindow')."""
281+
"""Filter elements using ifcopenshell selector syntax.
282+
283+
Examples: ``IfcWall``, ``IfcWall, IfcColumn``, ``! IfcWall``,
284+
``IfcWall, Name = "My Wall"``, ``type = "Concrete Wall"``,
285+
``material = "Concrete"``.
286+
"""
282287
return select.select(self._require_model(), query)
283288

284289
def ifc_relations(self, element_id: int, traverse: str = "") -> dict[str, Any] | list[dict[str, Any]]:
@@ -536,7 +541,12 @@ def openai_tools(self) -> list[dict[str, Any]]:
536541
{
537542
"type": "function",
538543
"name": "ifc_select",
539-
"description": "Select elements using ifcopenshell selector syntax (e.g. 'IfcWall').",
544+
"description": (
545+
"Select elements using ifcopenshell selector syntax. "
546+
"Examples: 'IfcWall', 'IfcWall, IfcColumn', '! IfcWall', "
547+
"'IfcWall, Name = \"My Wall\"', 'type = \"Concrete Wall\"', "
548+
"'material = \"Concrete\"'."
549+
),
540550
"parameters": {
541551
"type": "object",
542552
"properties": {"query": {"type": "string"}},

src/ifcquery/ifcquery/select.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,16 @@
2626

2727

2828
def select(model: ifcopenshell.file, query: str) -> list[dict[str, Any]]:
29-
"""Filter elements using selector syntax and return matching element summaries."""
29+
"""Filter elements using ifcopenshell selector syntax and return matching element summaries.
30+
31+
Examples:
32+
- ``IfcWall`` — all walls
33+
- ``IfcWall, IfcColumn`` — walls and columns
34+
- ``! IfcWall`` — everything except walls
35+
- ``IfcWall, Name = "My Wall"`` — walls with a specific name attribute
36+
- ``type = "Concrete Wall"`` — elements assigned that type product
37+
- ``material = "Concrete"`` — elements with that material
38+
"""
3039
elements = ifcopenshell.util.selector.filter_elements(model, query)
3140
results = []
3241
for element in sorted(elements, key=lambda e: e.id()):

0 commit comments

Comments
 (0)