sách gpt4 ai đã đi

c# - 如何获取具体IfcElement的 Material 数据

In lại 作者:行者123 更新时间:2023-12-05 05:02:04 31 4
mua khóa gpt4 Nike

在xbim例子中的基本操作https://docs.xbim.net/examples/basic-model-operations.html ,它展示了如何检索特定 IfcElement 的单值属性。基于此,我尝试获取 Material 数据。

我写了以下内容:

var id = "3NBPkknun6EuV9fpeE6rFh";

var theWall = model.Instances.FirstOrDefault(d => d.GlobalId == id);

var materials = theWall.HasAssociations
.Where(r => r.RelatingMaterial is IIfcMaterialProfileSet)
.SelectMany(r=> ((IIfcMaterialProfileSet)r.RelatingMaterial).MaterialProfiles)
.OfType();

Nó cho tôi lỗi này:

'IIfcRelAssociates' does not contain a definition for 'RelatingMaterial' and no accessible extension method 'RelatingMaterial' accepting a first argument of type 'IIfcRelAssociates' could be found (are you missing a using directive or an assembly reference?)

我知道我必须使用 IfcRelAssociatesMaterial,但我不知道如何使用。如何检索 Material 信息?

1 Câu trả lời

IIfcObjectDefinition 的 HasAssociations返回一组 IIfcRelAssociates但您只需要派生类型 IIfcRelAssociatesMaterial其中有 RelatingMaterial属性(property)。参见 https://standards.buildingsmart.org/IFC/RELEASE/IFC4/ADD2/HTML/schema/ifcproductextension/lexical/ifcrelassociatesmaterial.htm

因此,只需添加 .OfType 即可将查询限制为 Material 关联。即

var materials = theWall.HasAssociations.OfType() 
// rest of the query

关于c# - 如何获取具体IfcElement的 Material 数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62406787/

31 4 0
行者123
Hồ sơ cá nhân

Tôi là một lập trình viên xuất sắc, rất giỏi!

Nhận phiếu giảm giá Didi Taxi miễn phí
Mã giảm giá Didi Taxi
Giấy chứng nhận ICP Bắc Kinh số 000000
Hợp tác quảng cáo: 1813099741@qq.com 6ren.com