SuperAPI AI 工具集

ifcos-syntax-elements

数据与分析

查看项目

更新于 10-15 22:17

技能介绍

用途:在 IfcOpenShell 中查询、遍历与提取 IFC 元素数据,包括按类型、STEP ID、GlobalId 查找,反向引用遍历,以及属性集与数量集提取。

主要能力:model.by_type("IfcWall") 按 IFC 类查询,默认包含子类型,可用 include_subtypes=False 仅取精确类型;model.by_id(123) 按 STEP ID 查询;model.by_guid("...") 按 22 字符 GlobalId 查询;model.get_inverse(element) 获取引用该元素的实体,用于定位所在楼层、属性集、类型对象、开洞等;element.get_info()、element.is_a()、element.id() 读取属性与判断类型;ifcopenshell.util.element.get_psets、get_type、get_container、get_material 等等辅助函数;ifcopenshell.util.selector.filter_elements 支持类似 CSS 的选择器过滤。

使用方式:先 import ifcopenshell 并 model = ifcopenshell.open("model.ifc"),再调用上述方法;生成 GlobalId 使用 ifcopenshell.guid.new(),可用 expand/compress 与标准 UUID 互转。属性提取推荐用 ifcopenshell.util.element.get_psets,手动遍历 IsDefinedBy → IfcRelDefinesByProperties → IfcPropertySet → HasProperties → wrappedValue 仅在需要细粒度控制时使用。

限制与注意:STEP ID 在文件重新导出后会变化,不可作持久标识,跨会话识别应使用 GlobalId;只有 IfcRoot 派生实体才有 GlobalId;get_info(recursive=True) 在大模型上开销极大,避免在循环中调用;可选属性可能返回 None,访问前需判空;prop.NominalValue 为 None 时应先检查再访问 .wrappedValue;by_id 与 by_guid 未找到时抛 RuntimeError,by_type 无匹配返回空元组。查询 API 跨 IFC2X3、IFC4、IFC4X3 通用,仅实体类名随 schema 不同。