How can I get only the displayed elements for the user from the detail view?

How can I get only the displayed elements for the user from the detail view?

jejeno2544
Participant Participant
352 Views
3 Replies
Message 1 of 4

How can I get only the displayed elements for the user from the detail view?

jejeno2544
Participant
Participant

Hi all,

Let's discuss the next model with pipes:

jejeno2544_2-1666259558407.png

The peculiarity of the current model is that pipes 1 and 2 are in one line.

And if we change the view to the front view.

jejeno2544_3-1666259631546.png

As a result, the user sees only pipe 1, but it should be remembered that behind it there is the same pipe 2.


Let's create a detail view for model. 

jejeno2544_4-1666259789448.png


And here's the question, how do I use Revit API to get the id of pipe 1 only and skip the id of pipe 2 (pipe 2 is shown in the first screenshot) for the Elevation Front View?

0 Likes
353 Views
3 Replies
Replies (3)
Message 2 of 4

Omar_Amen
Advocate
Advocate

Hi @jejeno2544 ,
then your question is how to get elements that be only visible in the view,  
if you used the FilteredElementCollector(Document doc, ElementId ViewId) you will get the element that the view box contains!
in other words you will get pipe1 and also pipe2 although the pipe2 is totally culled by pipe1,
so the solution logic here depends only on what are the elements that actually can be seen in the view,
I'm going to suggest using the RAYCASTING methodology,
you can use  ReferenceIntersector(View3D view3d) / FindNearest(XYZ origin, XYZ direction) 
to cast the rays in the 3d and then exclude the element that have not been appeared in the ray projection process
this will work fine in 3d views after calculating the directions and the density of rays that you will need.

I hope this will help,

Message 3 of 4

Omar_Amen
Advocate
Advocate

and If you want to get that but in 2d detail view, can you simulate the process by getting the detail view box then create a 3d view with that box, do the raycasting process then delete the created view after getting the result?

0 Likes
Message 4 of 4

jejeno2544
Participant
Participant

Sorry, I forgot to enter the name of the view.
What I mean is that I only want pipe IDs for the Elevation Front View: 

jejeno2544_0-1666594541806.png

How do I use Revit API to get the id of pipe 1 only and skip the id of pipe 2 (pipe 2 is shown in the first screenshot) for the Elevation Front View?