首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >xBim ifc操作:尝试添加属性集

xBim ifc操作:尝试添加属性集
EN

Stack Overflow用户
提问于 2020-03-16 17:51:28
回答 1查看 526关注 0票数 0

我试图用ifc2x3来操作xBim文件。它基于示例:https://docs.xbim.net/examples/basic-model-operations.html

但是,当涉及到var pSetRel = model.Instances.New<IfcRelDefinesByProperties>时,它会与System.Exception: "This factory only creates types from its assembly"崩溃--下面是代码:

代码语言:javascript
复制
string fileName = modelsPath + "Duplex_A_20110907.ifc";

using (var model = IfcStore.Open(fileName))
{
    //get existing wall from the model
    var id = "2O2Fr$t4X7Zf8NOew3FNld";
    var wall = model.Instances.FirstOrDefault<IfcWall>(d => d.GlobalId == id);

    //open transaction for changes
    using (var txn = model.BeginTransaction("Walls modification"))
    {
        //create new property set with two properties
        var pSetRel = model.Instances.New<IfcRelDefinesByProperties>(r =>
        {
            r.GlobalId = Guid.NewGuid();
            r.RelatingPropertyDefinition = model.Instances.New<IfcPropertySet>(pSet =>
            {
                pSet.Name = "New property set";
                //all collections are always initialized
                pSet.HasProperties.Add(model.Instances.New<IfcPropertySingleValue>(p =>
                {
                    p.Name = "First property";
                    p.NominalValue = new IfcLabel("First value");
                }));
                pSet.HasProperties.Add(model.Instances.New<IfcPropertySingleValue>(p =>
                {
                    p.Name = "Second property";
                    p.NominalValue = new IfcLengthMeasure(156.5);
                }));
            });
        });

        //change the name of the door
        wall.Name += "_checked";
        //add properties to the door
        pSetRel.RelatedObjects.Add(wall);

        //commit changes
        txn.Commit();
    }

    model.SaveAs(modelsPath + "/Duplex_A_20110907_modified.ifc");
}

我做错什么了?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2020-03-17 09:22:55

您还没有包含using语句,但我想您引用的是IfcRelDefinesByProperties的Ifc4版本,而不是Ifc2x3等效的版本。

不能混合和匹配架构实体。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/60710873

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档