Using xBim Geometry Conversion in the New Asp.Net Project Format

Georg Dangl by Georg Dangl in DotNet Thursday, February 02, 2017

Thursday, February 02, 2017

Using xBim Geometry Conversion in the New Asp.Net Project Format
Posted in BIM Asp.Net Core

Recently at work, we were evaluating a few options to render building models in the browser. Building Information Modeling (BIM) in interoperability scenarios is done via Industry Foundation Classes, mostly in the STEP Physical File format. The schema is quite huge and complex with all the things you have to consider, so we were glad to find the xBim open source project on GitHub. They've got both projects to visualize building models in the browser with WebGL as well as conversion tools to create the binary-formatted geometry mesh. To achieve that, native C++ libraries are dynamically loaded (so no .Net Core compatibility) which must be present in the bin folder. The C++ libraries are expected either in the same folder as the application binaries or in a x64 (or x86, respectively) sub folder (See here for more details). In regular projects, the xBim.Geometry NuGet package adds a build task to copy the dlls into the build output folder, but this doesn't work with the new tooling. You can, however, get it to work in Visual Studio 2015 by taking care of supplying the interop dlls yourself.

Add a PowerShell file to the root of your project that takes care of copying the C++ dlls from the NuGet package cache to your project:

Now you need to define three things in the project.json file:

  1. A precompile command that invokes the above PowerShell script before each build. That comes with the side effect of breaking incremental build, but there's no way around that currently.
  2. buildOptions:copyToOutput:mappings entry to copy the interop dlls to the build output folder
  3. publishOptions:mappings to copy the interop dlls to the publish output folder (and I have no idea why this doesn't already take the buildOptions into account, but that's the way it is I guess)

Here's a (shortened) project.json file with the configuration:

I've created a small sample web app that's also available on GitHub. This app already makes use of Angular 2 and the TypeScript version of xBimWebUI which isn't yet merged in the original repository, so you should take a look at my fork until it's accepted.

Building Model rendered with WebGL in the Browser (with xBim)

Happy meshing!


Share this post


comments powered by Disqus

About me

Hi, my name's George! I love coding and blogging about it. I focus on all things around .Net, Web Development and DevOps.

DanglIT

Need a consultant for BIM, GAEB or Software Development?

Contact me at [email protected], +49 (173) 56 45 689 or visit my professional page!

Dangl.Blog();
// Just 💗 Coding

Social Links