This section uses the iModel Console to execute queries against the Stadium
sample iModel.
See Aspect Queries for instructions on opening an iModel in the iModel Console.
iModels have a special spatial index table to make spatial queries fast and builtin functions to make querying a bit easier. See learning docs and the tutorial
-
Find the bounding box of an element
SELECT * FROM bis.SpatialIndex WHERE ECInstanceId = 0x200000063de
Remember find an Id from your own iModel.
-
Find Elements within a bounding box
SELECT e.ECInstanceId, c.codevalue FROM Generic.PhysicalObject e JOIN bis.Category c ON c.ECInstanceId = e.Category.Id WHERE e.ECInstanceId IN ( SELECT ECInstanceId FROM bis.SpatialIndex WHERE minx > 32575 AND maxx < 32690 AND miny > 31720 AND maxy < 31800 AND minz > 5.5 AND maxz < 36 )
NOTE: Joining on category is not necessary but it is informative.
-
Find only the glass within the bounding box
SELECT e.ECInstanceId, c.codevalue, a.* FROM Generic.PhysicalObject e JOIN bis.Category c ON c.ECInstanceId = e.Category.Id JOIN DgnCustomItemTypes_SS_Steel_Structure.GlassElementAspect a ON a.Element.Id = e.ECInstanceId WHERE e.ECInstanceId IN ( SELECT ECInstanceId FROM bis.SpatialIndex WHERE minx > 32575 AND maxx < 32690 AND miny > 31720 AND maxy < 31800 AND minz > 5.5 AND maxz < 36 )