xBIM 基础07 创建WebBIM文件

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

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();
                }
            }
        }
    }
}
 
posted @ 2019-06-04 09:27  张传宁  阅读(1230)  评论(0编辑  收藏  举报
页脚 HTML 代码