To make it easier to interact with the OpenSource BIMserver from a web environment (like a browser or NodeJS) you can use this library. This library uses the ECMAScript6 Modules concept. Not all browsers support this yet.
The "?_v=%VERSION%" additions are there for efficient caching purposes. Any server system serving these files can tell the client to cache these files indefinitely.
<head>
<script type="module" src="bimserverapipromise.js?_v=%VERSION%"></script> <script type="module" src="bimserverapiwebsocket.js?_v=%VERSION%"></script> <script type="module" src="bimserverclient.js?_v=%VERSION%"></script> <script type="module" src="ifc2x3tc1.js?_v=%VERSION%"></script> <script type="module" src="ifc4.js?_v=%VERSION%"></script> <script type="module" src="model.js?_v=%VERSION%"></script> <script type="module" src="translations_en.js?_v=%VERSION%"></script>Combined minified version (only available on a released version): bimserverapi.js?_v=%VERSION%
// Import the library, all dependencies will be handled by the module system
import BimServerClient from './bimserverclient.js';
// Create a new API, the path given should point to the base path of a BIMserver. This can also be a full URL like "http://bimserveraddress"
var api = new BimServerClient("../..");
api.init((client, version) => {
console.log(version.version);
});
// When the location on the API is not known in advance, you can use dynamic loading, in most browsers you'll need to use a "dev" version for this to work (Chrome 64 for example).
var address = "http://addressofapi";
Promise.all([
address + "/bimserverclient.js",
address + "/bimserverapipromise.js"
].map(x => import(x)))
.then(([BimServerClient, BimServerApiPromise]) => {
var api = new BimServerClient.BimServerClient("../..");
api.init((client, version) => {
document.getElementById("version").innerHTML = JSON.stringify(version.version, 0, 2);
});
});