首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Xbim几何错误

Xbim几何错误
EN

Stack Overflow用户
提问于 2017-02-14 08:58:46
回答 1查看 1.5K关注 0票数 0

我正在使用以下C#代码来访问ifc4文件中的几何数据。该文件仅包含使用Revit 2016创建的墙。我正在使用Xbim库。这是我的代码:

代码语言:javascript
复制
class Program
{
    private static readonly ILog logger =
       LogManager.GetLogger(typeof(Program));
    static string _ifcFile = @"C:\Examples\OneWall.ifc";

    static void Main(string[] args)
    {
        BasicConfigurator.Configure();

        IfcStore model = IfcStore.Open(_ifcFile);
        Xbim3DModelContext context = new Xbim3DModelContext(model);
        context.CreateContext();
        XbimMeshGeometry3D mesh = mesh = (XbimMeshGeometry3D)context.ShapeGeometryMeshOf(context.ShapeInstances().FirstOrDefault());

        //The rest of my code
    }
} 

我得到以下错误。我使用的是visual studio 2015。

1226 1调试Xbim.Geometry.Engine.Interop.XbimCustomAssemblyResolver (空)-正在从以下位置加载程序集: C:\Examples\ifcWall\ifcWall\bin\Debug\x86\Xbim.Geometry.Engine32.dll 1404 1调试Xbim.Geometry.Engine.Interop.XbimCustomAssemblyResolver (空)-正在从以下位置加载程序集: C:\Examples\ifcWall\ifcWall\bin\Debug\x86\Xbim.Geometry.Engine32.dll

未处理的异常: Xbim.ModelGeometry.Scene.XbimMeshGeometry3D.Read(String数据上的几何图形命令无效,可为空的1 trans) in c:\BuildAgent\work\860c3b913b6c647f\Xbim.ModelGeometry.Scene\XbimMeshGeometry3D.cs:line 219 at Xbim.ModelGeometry.Scene.XbimMeshGeometry3D.Add(String mesh, Int16 productTypeId, Int32 productLabel, Int32 geometryLabel, Nullable1转换,c:\BuildAgent\work\860c3b913b6c647f\Xbim.ModelGeometry.Scene\Xbim3DModelContext.cs:line 1525中的c:\BuildAgent\work\860c3b913b6c647f\Xbim.ModelGeometry.Scene\XbimMeshGeometry3D.cs:line 669中的Int16 modelId)和C:\Users\karshenas\Documents\Courses\CEEN6840\VS_Projects\ifcWall\ifcWall\Program.cs:line 26中的ifcWall.Program.Main(String[]参数)

任何帮助修复该错误的人都将不胜感激。

EN

回答 1

Stack Overflow用户

发布于 2017-03-21 22:58:17

您遇到了API已更改的区域,并且此特定函数需要不同格式的数据。如果您需要的是形状的三角测量,则此代码应该适用于您:

代码语言:javascript
复制
using System.IO;
using Xbim.Common.Geometry;
using Xbim.Ifc;
using Xbim.ModelGeometry.Scene;
using Xbim.Common.XbimExtensions;

namespace CreateWexBIM
{
    class Program
    {
        static void Main(string[] args)
        {
            const string file = @"4walls1floorSite.ifc";

            var model = IfcStore.Open(file);
            var context = new Xbim3DModelContext(model);
            context.CreateContext();

            var instances = context.ShapeInstances();
            foreach (var instance in instances)
            {
                var geometry = context.ShapeGeometry(instance);
                var data = ((IXbimShapeGeometryData)geometry).ShapeData;
                using (var stream = new MemoryStream(data))
                {
                    using (var reader = new BinaryReader(stream))
                    {
                        var mesh = reader.ReadShapeTriangulation();
                    }
                }
            }
        }

    }
}

最好的方法是在xBIM GitHub Issues中请求并共享文件。IFC几何可能会变得非常复杂,因此不可能仅仅基于异常来真正回答您的问题。

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

https://stackoverflow.com/questions/42216138

复制
相关文章

相似问题

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