mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-05 23:41:44 +00:00
ifcquery, ifcmcp: better bot selector syntax hints
This commit is contained in:
@@ -278,7 +278,12 @@ class IfcSession:
|
||||
return info.info(model, element)
|
||||
|
||||
def ifc_select(self, query: str) -> list[dict[str, Any]]:
|
||||
"""Filter elements using ifcopenshell selector syntax (e.g. 'IfcWall', 'IfcWindow')."""
|
||||
"""Filter elements using ifcopenshell selector syntax.
|
||||
|
||||
Examples: ``IfcWall``, ``IfcWall, IfcColumn``, ``! IfcWall``,
|
||||
``IfcWall, Name = "My Wall"``, ``type = "Concrete Wall"``,
|
||||
``material = "Concrete"``.
|
||||
"""
|
||||
return select.select(self._require_model(), query)
|
||||
|
||||
def ifc_relations(self, element_id: int, traverse: str = "") -> dict[str, Any] | list[dict[str, Any]]:
|
||||
@@ -536,7 +541,12 @@ class IfcSession:
|
||||
{
|
||||
"type": "function",
|
||||
"name": "ifc_select",
|
||||
"description": "Select elements using ifcopenshell selector syntax (e.g. 'IfcWall').",
|
||||
"description": (
|
||||
"Select elements using ifcopenshell selector syntax. "
|
||||
"Examples: 'IfcWall', 'IfcWall, IfcColumn', '! IfcWall', "
|
||||
"'IfcWall, Name = \"My Wall\"', 'type = \"Concrete Wall\"', "
|
||||
"'material = \"Concrete\"'."
|
||||
),
|
||||
"parameters": {
|
||||
"type": "object",
|
||||
"properties": {"query": {"type": "string"}},
|
||||
|
||||
@@ -26,7 +26,16 @@ import ifcopenshell.util.selector
|
||||
|
||||
|
||||
def select(model: ifcopenshell.file, query: str) -> list[dict[str, Any]]:
|
||||
"""Filter elements using selector syntax and return matching element summaries."""
|
||||
"""Filter elements using ifcopenshell selector syntax and return matching element summaries.
|
||||
|
||||
Examples:
|
||||
- ``IfcWall`` — all walls
|
||||
- ``IfcWall, IfcColumn`` — walls and columns
|
||||
- ``! IfcWall`` — everything except walls
|
||||
- ``IfcWall, Name = "My Wall"`` — walls with a specific name attribute
|
||||
- ``type = "Concrete Wall"`` — elements assigned that type product
|
||||
- ``material = "Concrete"`` — elements with that material
|
||||
"""
|
||||
elements = ifcopenshell.util.selector.filter_elements(model, query)
|
||||
results = []
|
||||
for element in sorted(elements, key=lambda e: e.id()):
|
||||
|
||||
Reference in New Issue
Block a user