Host.FindInserts Method returnin more elements than expected.

juninhopaica
Contributor
Contributor

Host.FindInserts Method returnin more elements than expected.

juninhopaica
Contributor
Contributor

Hi everyone.

I the last week I had a little problem to solve and I decided to implement some of the knowledge I gathered of the Revit API to solve this problem. In my research I came across an awesome Method that host objects have called "FindInserts" (https://www.revitapidocs.com/2015/58990230-38cb-3af7-fd25-96ed3215a43d.htm). 

Basically, this method allows the user to retrive all the hosted elements Id of an Host Object in Revit, really powerfull!

One thing that I found is that the second argument of this method retrive something called "Shadows". I'm not gonna talk a lot about what these are, since the friend Jeremy Tammik answered this question already (https://forums.autodesk.com/t5/revit-api-forum/findinserts-what-does-includeshadows-flag-do/td-p/920...).

 

In resume, Shadows are elements, like openings, that are created by the elements hosted on a host Object (Like a wall or a floor). After finding this I decided to experiment this method, but I found a interesting behavior. To explain this, lets get the little example I have below. 

juninhopaica_0-1652726902441.png

 

Lets call the gray wall "Core Wall" and the white wall "Hosted Wall". As we can see the Core Wall has 5 elements that are hosted in her (2 Doors and 3 Windows). However, the Hosted Wall don't have any element inserted, but because this wall was joined with the Core Wall, 4 opennings were created by Revit in the Wall.

My experiment was simple. I was going to use the little macro below, and see the result.

Document doc = DocumentManager.Instance.CurrentDBDocument;

Wall wall = doc.GetElement(uidoc.Selection.PickObject(ObjectType.Element)) as Wall;

string textMessage = wall.Name + "\n\n";

foreach (ElementId id in wall.FindInserts(false, true, false, false))
{
      textMessage += $"{doc.GetElement(id).Name} \n";
}

TaskDialog.Show("Message", textMessage);

Since only the second argument of the FindInserts was "true" I was hoping that when I selected the Core Wall, the message in the end would return all the 5 elements, because they are hosted in this wall and make a openning in her. But I was also hoping that when I selected the Hosted Wall I would get her name and only 4 elements, because only 4 make an openning in her due to them being joined.

The result was as follow:

For the Core Wall.

juninhopaica_1-1652727373386.png

 

For the Hosted Wall.

juninhopaica_2-1652727403390.png

 

Oddly, in the Hosted Wall we also get 5 elements, but only 4 make a openning in the Hosted Wall. I am not sure if this is a Bug, or a intended feature, but I found interesting and wanted to share with everyone. I have also found a solution to this problem with the use of the "Reference Intersector Class" (https://www.revitapidocs.com/2015/36f82b40-1065-2305-e260-18fc618e756f.htm), but I wanted  to see other peoples thoughts on the matter. 

0 Likes
Reply
Accepted solutions (1)
251 Views
2 Replies
Replies (2)

RPTHOMAS108
Mentor
Mentor
Accepted solution

Seems odd but have you also tried the below which appears to do what you was looking for:

Wall.FindInserts(False, False, False, True) 

or even

Wall.FindInserts(False, False, False, False) 

 

Last boolean is includeSharedEmbeddedInserts

This may be for something else.

 

GetDependantElements also appears to just list the instances inserted on that particular wall.

 

The term 'Shared' alone is also not helpful because that terminology is already used in Revit for a specific purpose and this doesn't at first glance appear to be related to that.

 

For posterity it should also be noted that the term rectangular opening is also specifically about openings created with the rectangular wall opening tool as opposed to the form of most doors and windows you'll find in a wall.

 

 

 

 

0 Likes

juninhopaica
Contributor
Contributor

Hello my friend, I have triste with ALL the options from below...

 

FindInserts(true,false,false,false)

FindInserts (false,true,false,false)

FindInserts (false,false,true,false)

FindInserts (false,false,false,true)

 

Im gonna try with All false, but the problem was the fact that It actually returned more than It should have. 

 

But I found a workaround this 

0 Likes