目录
xBIM 有一个WebGL 插件。那么Web显示加载文件WexBIM文件。那么需要将文件转换为WebBIM文件。当你想将IFC转换成紧凑的wexBIM时,第一次去哪里看看就不是很明显,所以这里是代码。您将需要xBIM Essentials和xBIM几何。这里是非常简单的代码,用于将完整的IFC文件转换为wexBIM文件。因为xBIM是一个工具包,所以有办法如何定制/过滤高级部署的wexBIM文件,但这比简单的转换要复杂得多:
下面案例 将IFC 文件转换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(); } } } } }
简单HTML 案例
<!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>Hello building!</title> <script src="js/xbim-viewer.debug.bundle.js"></script> </head> <body> <div id="content"> <canvas id="></canvas> <script type="text/javascript"> var viewer = new xViewer('viewer'); viewer.load('data/SampleHouse.wexbim'); viewer.start(); </script> </div> </body> </html>