¿Hablas BIS?

Roop Saini
iTwin.js
Published in
4 min readJun 22, 2020

“How do I read data from an iModel?”

The question that has been eluding the community!

We have lots of new developers joining our ranks. They have been thrilled to see what iModel.js has to offer…yet they all seem to have one common complaint.

This takes me back to the first time I had to read data from an iModel. My challenge was to implement a feature called cross-probing — this involves clicking on a 3D element, and zooming into its 2D counterpart and vice versa. Here’s a sneak peak:

Holy smokes! I was new to the job and expected to do that?!

I had no experience querying data from an iModel. I imagined this would involve writing a pretty complex query that could map all the 3D elements to their related 2D elements, and connect everything in between.

Here is the tale of how I attempted to slay this dragon.

First let’s set the stage — if we are going to interact with our iModel, we need to first speak its language. That’s where the schema comes in. The schemas of an iModel define how data is stored within it. Each industry in Infrastructure — such as Railway, Building, Manufacturing, Civil, etc — will have its own unique set of schemas. You may think:

Dang, that’s a lot of schemas.

Do I have to understand all of them??

If only there was a common tongue that every iModel could speak —

Enter BIS

BIS is the base set of schemas of every iModel. It contains all the basic types of data that any infrastructure project would contain — such as the 2D and 3D elements above. This is where we can begin to discover the contents of any given iModel.

In the case of my cross-probing data dragon…we have an iModel originally sourced from a Plant design application. But the task is to click on a 3D element and zoom into its 2D counterpart — both of which are BIS based. We may not even have to worry about the advanced Plant schemas!

There are two main things to focus on when first exploring a schema:

  • What type of elements does it contain?
    => This is the class of an element.
    For example a 3D element is of class GeometricElement3D; 2D element is of class GeometricElement2D.
  • How are they related?
    => This is what we call a relationship between elements.
    How is a 3D element related to a 2D element? This is what we need to figure out to perform the magic of cross-probing.

Going back to our tale…it took me several espresso fueled hours, but this is the query I ended up with.

Please don’t freak out :)

In case your heart just skipped a beat…Congratulations! You have passed the test 🥳

The good news is that I didn’t have to fight this battle alone, and neither will you. Thankfully, we have some really effective tools and documentation that will empower you to work through the process. Let’s walk through it step-by-step to see how you can make it happen.

As promised in the clips…here are some links to unleash the data within your Digital Twins:

iModel Console: Run queries against your iModel.

ECSQL Tutorial: Learn how to construct your own ECSQL queries.

Log Element-IDs: Start investigating specific elements.

Create iModel: To get “Bay Town Process Plant” example used above.

BIS Docs: Study core BIS concepts.

ECSQL Join: Learn how to join relationships and elements.

Finally — once I had cross-probing down — I was able to apply the same core principles to go beyond BIS and write queries against specialized schemas. Hopefully this is enough material for you to get back in there and slay your own dragon.

-Roop, reporting live from the basement.

<- previous post | home | next post ->

--

--