itwinjs-core icon indicating copy to clipboard operation
itwinjs-core copied to clipboard

Window Select only selects what is visible

Open DRHoltman opened this issue 9 months ago • 10 comments

Description We currently have items with multiple elements that we are trying to convert and consolidate. When we select multiple elements using the window select tool

Image

It selects the items visible to the user Image

But if you rotate to the back side, you will notice that the items on the back side did not get selected: Image

Is this by design? Or is this a bug? Or is there another way to do this?

To Reproduce I'm attaching a bim file to be used to reproduce. meppipieces.bim

We have reproduced in the display-test-app: Image

Version iTwin.js: 4.10.13 iTwinUI: 3.1.4 AppUI: 5.3.1 React: 18.3.1 Node.js: 20.18.1 Electron: 33.2.1

DRHoltman avatar May 19 '25 12:05 DRHoltman

Have you tried modifying the Selection Scopes ?

aruniverse avatar May 19 '25 14:05 aruniverse

Is this by design? Or is this a bug?

It is by design. People tend to find it surprising if, e.g,, selecting the exterior walls of a building quietly also selects all the elements they can't see inside the building.

Or is there another way to do this?

You could use a spatial query to find elements that intersect your rectangle. @bbastings might have advice or examples.

pmconne avatar May 19 '25 15:05 pmconne

Volume query example

Have you tried modifying the Selection Scopes ?

Selection scope could help here if you are creating these elements as part of an assembly. Note: display-test-app does not support selection scope.

bbastings avatar May 19 '25 15:05 bbastings

The screen shots above are using the element selection scope. We will look into adding the spatial query as Paul mentioned above. Thanks Guys.

DRHoltman avatar May 21 '25 14:05 DRHoltman

Unfortunately the query for volume selection isn't returning any elements from meppipieces.

  const viewedModels = [...vp.view.modelSelector.models].join(",");
  const viewedCategories = [...vp.view.categorySelector.categories].join(",");
  const ecsql = `SELECT e.ECInstanceId, Category.Id as category FROM bis.SpatialElement e JOIN bis.SpatialIndex i ON e.ECInstanceId=i.ECInstanceId WHERE Model.Id IN (${viewedModels}) AND Category.Id IN (${viewedCategories}) AND i.MinX <= ${range.xHigh} AND i.MinY <= ${range.yHigh} AND i.MinZ <= ${range.zHigh} AND i.MaxX >= ${range.xLow} AND i.MaxY >= ${range.yLow} AND i.MaxZ >= ${range.zLow}`;
  const reader = vp.iModel.createQueryReader(ecsql, undefined, { rowFormat: QueryRowFormat.UseECSqlPropertyNames });

The problem isn't the model, category, or range restrictions. I checked a couple elements, everything looks good and they are in the spatial index?!?

bbastings avatar May 26 '25 02:05 bbastings

@bbastings Does your response mean that spatial query will not work for them?

@markschlosseratbentley I wasn't able to figure out why my query didn't work in their file, it does in other files I tested (need query expert). The hope was that people that wanted volume selection could just set ToolSettings.enableVolumeSelection to true and the select tool along will all other tools that support drag box selection would just work.

markschlosseratbentley avatar Oct 02 '25 15:10 markschlosseratbentley

I wasn't able to figure out why my query didn't work in their file, it does in other files I tested (need query expert).

@aruniverse do you know who is a query expert we can loop into this conversation?

markschlosseratbentley avatar Oct 02 '25 16:10 markschlosseratbentley

I wasn't able to figure out why my query didn't work in their file, it does in other files I tested (need query expert).

@aruniverse do you know who is a query expert we can loop into this conversation?

@khanaffan

aruniverse avatar Oct 02 '25 16:10 aruniverse

I have the BIM file from the issue. I can see the query. But what I need is query with parameters filled out. I’ve reviewed the BIM file related to the issue and located the SQL query. However, what I need is the fully resolved query—with all parameters (like viewedModels, viewedCategories, and range) filled in with actual values.

Here’s the query template for reference:

SELECT e.ECInstanceId, Category.Id as category 
FROM bis.SpatialElement e 
JOIN bis.SpatialIndex i ON e.ECInstanceId = i.ECInstanceId 
WHERE Model.Id IN (${viewedModels}) 
  AND Category.Id IN (${viewedCategories}) 
  AND i.MinX <= ${range.xHigh} 
  AND i.MinY <= ${range.yHigh} 
  AND i.MinZ <= ${range.zHigh} 
  AND i.MaxX >= ${range.xLow} 
  AND i.MaxY >= ${range.yLow} 
  AND i.MaxZ >= ${range.zLow};

Could you help provide the query with those placeholders replaced by actual values?

khanaffan avatar Oct 02 '25 16:10 khanaffan

@khanaffan Thanks for having a look...

SELECT e.ECInstanceId, Category.Id as category FROM bis.SpatialElement e JOIN bis.SpatialIndex i ON e.ECInstanceId=i.ECInstanceId WHERE Model.Id IN (0x17) AND Category.Id IN (0x8d,0x1d) AND i.MinX <= 6.254427909851074 AND i.MinY <= 1.5976687669754028 AND i.MinZ <= 4.996658802032471 AND i.MaxX >= 2.0561231486102374 AND i.MaxY >= -3.7628626041133995 AND i.MaxZ >= -100

^ Box select in top view shown below:

Image

bbastings avatar Oct 02 '25 18:10 bbastings