imodeljsjumpstart.github.io

View on GitHub

Challenge: Display all user labels associated with spatial elements in a confined cube.

Summary

By completing this you will learn how to:

Setup

  1. Go to the getting started registration dashboard (If you haven’t registered yet, please register a new account)
  2. Click on “New iModel”
  3. Name the imodel whatever you like (i.e. “My House Sample”).
  4. In the drop down menu, select “House Sample”.
  5. Click on “submit” and allow the process to complete.
  6. Navigate to the imodel console.
  7. Follow the sign in process to gain access to the console.
  8. (Optional): Read through the quick tips and do the tutorial.
  9. (Optional): If you’re not familiar with ECSQL/SQL, check out our learning page

Instructions

Once the setup is complete, we’ll need to open the imodel you’ve just cloned using the imodel console.

Opening your imodel in the console.

  1. Click on your project name in the table under “Listing all Contexts” to display imodels associated with the project
  2. Click on your imodel name in the table under “Listing iModels from Project” to display changets associated with the project
  3. Click on the named version id to finally open the imodel.

Congratulations! The imodel is now open and ready for queries.

Steps to complete the challenge

1) Begin by listing all EC properties available for all spatial elements in the imodel.

Hint For Step 1

Solution Step 1

2) Instead of displaying all EC properties, write a query that only lists the EC properties we’re interested in: “ECInstanceId”, “UserLabel” and “Origin”

Hint For Step 2

Solution Step 2

3) While the origin locates where the spatial element is, the size is still unknown. We need to query from the class “Bis.SpatialIndex” for this.

Solution For Step 3

4) Notice how SpatialIndex contains the range but it doesn’t contain ‘UserLabel’. We need to JOIN class Bis.SpatialElement and class Bis.SpatialIndex together.

Hint 1 For Step 4

Hint 2 For Step 4

Hint 3 For Step 4

Solution For Step 4

5) Once again the data shown is too verbose. Only pull the information we want to see.

Hint For Step 5

Solution For Step 5

6) Now that we have all the information we need, it’s time to add a simple condition.

Hint For Step 6

Solution For Step 6

7) The final challenge is to retrieve the user labels of all spatial elements that are contained in a cube with the minimum bounding coordinate at (5, 6, 6) and maximum bounding coordinate at (15, 15, 14).

Solution For Challenge

Conclusion

So, were you up to the challenge? Feel free to explore the console and experiment with your own queries. You can learn much more about how ECSQL queries work here.

Feedback is welcome! Let us know via the iModel.js community.