- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
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.
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.
For the Hosted Wall.
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.
Solved! Go to Solution.