Get FamilyInstance from room

Get FamilyInstance from room

Anonymous
Not applicable
1,318 Views
4 Replies
Message 1 of 5

Get FamilyInstance from room

Anonymous
Not applicable

I'm trying to get all the instances from the room with the following code. But he behaves differently. Sometimes he does not see the door, sometimes he sees a door, sometimes he finds an element of a door. Why is this happening?

foreach (Face face in geomsolidfaceslist)
{
List<Element> listelementfromwall = new List<Element>();

IList<SpatialElementBoundarySubface> subfaceList1 = results.GetBoundaryFaceInfo(face); // get the sub-faces for the face of the room
foreach (SpatialElementBoundarySubface subface in subfaceList1)
{

ElementId elemid = subface.SpatialBoundaryElement.HostElementId;
Element elem = doc.GetElement(elemid);
if (elem is Wall)
{
Wall wall = elem as Wall;
IList<ElementId> op = wall.FindInserts(true, true, true, true);

foreach (ElementId elementId in op)
{
listelementfromwall.Add(doc.GetElement(elementId));
}
}

}}

0 Likes
1,319 Views
4 Replies
Replies (4)
Message 2 of 5

jeremytammik
Autodesk
Autodesk

Dear Vadim,

 

There are a lot of ways to retrieve all family instances in a room.

 

You could also use an intersecting filtered element collector based on the room bounding box, or on the room solid:

 

http://thebuildingcoder.typepad.com/blog/2018/03/create-2d-arc-and-filter-for-intersecting-elements....

 

You could use the FamilyInstance Room property to ensure that it really does reside in the room:

 

http://www.revitapidocs.com/2018.1/37944e7a-f298-9c25-20bb-9c0c1da46f41.htm

 

Have you tested whether other approaches provide more reliable results?

 

Cheers,

 

Jeremy



Jeremy Tammik
Developer Technical Services
Autodesk Developer Network, ADN Open
The Building Coder

0 Likes
Message 3 of 5

Anonymous
Not applicable

Using the code from the example, I got 4 doors. Although in the room I have only two. it seems that the code found not only the doors of my room, but also the adjacent and inside part of the door that is in my room. How to deal with this, maybe you can do something about this?
Before that, I used the code from the first message that found the elements in the faces of the room, because I need to find the dots next to the doors on the faces. Which of the two is better? Both have problems with finding items. Is there a way to solve my problem?

 

 

Element e = Util.SelectSingleElement(
 uidoc, "a junction box");

BoundingBoxXYZ bbb = e.get_BoundingBox(null);

Outline outLne = new Outline(bbb.Min, bbb.Max);

// Use a quick bounding box filter - axis aligned

ElementQuickFilter fbb
= new BoundingBoxIntersectsFilter(outLne);

FilteredElementCollector conduits
= new FilteredElementCollector(doc)
.OfClass(typeof(FamilyInstance))
.OfCategory(BuiltInCategory.OST_Doors)
.WherePasses(fbb);

// How many elements did we find?

int nbb = conduits.GetElementCount();

0 Likes
Message 4 of 5

jeremytammik
Autodesk
Autodesk

Dear Vadim,

 

My suggestion is so obvious it is trivial:

 

1. Use whatever method works best to ensure that you get all of the required family instances. Too many is better than too few, I think!

 

2. Implement a post-processing algorithm to eliminate the ones you do not want.

 

Don't you agree?

 

I look forward to hearing how you end up solving this.

 

Thank you!

 

Cheers,

 

Jeremy



Jeremy Tammik
Developer Technical Services
Autodesk Developer Network, ADN Open
The Building Coder

0 Likes
Message 5 of 5

Anonymous
Not applicable

do you have an example how could this be done?

0 Likes