xBIM 基础07 创建WebBIM文件

2019-09-17 17:36:11 浏览数 (1)

  xBIM项目提供了一个IFC文件的Web查看器。当你想把IFC转换成紧凑的WexBIM时,需要 xBIM Essentials 和 xBIM Geometry 。下面是用于将完整的IFC文件转换为WexBIM文件的非常简单的代码。因为XBIM是一个工具包,所以有很多方法可以为高级部署定制/过滤WEXBIM文件,但这比这个简单的转换要复杂得多:

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

namespace CreateWexBIM
{
    class Program
    {
        public static void Main()
        {
            const string fileName = "SampleHouse.ifc";
            using (var model = IfcStore.Open(fileName))
            {
                var context = new Xbim3DModelContext(model);
                context.CreateContext();

                var wexBimFilename = Path.ChangeExtension(fileName, "wexBIM");
                using (var wexBiMfile = File.Create(wexBimFilename))
                {
                    using (var wexBimBinaryWriter = new BinaryWriter(wexBiMfile))
                    {
                        model.SaveAsWexBim(wexBimBinaryWriter);
                        wexBimBinaryWriter.Close();
                    }
                    wexBiMfile.Close();
                }
            }
        }
    }
}

0 人点赞