1571/2078

FindInserts Determines Void Instances Cutting Floor

Originally Published in

Is it hot enough for you?

It sure is for this guy:

Melted candle

Time for some rest and recuperation, meseems…

Before that, let me share another brilliant and super succinct solution provided by Fair59, answering the Revit API discussion forum thread on how to get cutting void instances in the floor using the HostObject FindInserts method:

Question: I have a floor on which a family instance is inserted on the face of the floor (the instance host is also the floor).

I checked in the family the “Cut with Void When Loaded” parameter, so that the void is created in the floor.

Now, I want to retrieve all the instances that create voids in the floor.

I did some research, and found the discussion of Boolean operations and InstanceVoidCutUtils.

But when I use the InstanceVoidCutUtils GetCuttingVoidInstances method, it returns an empty list.

I also looked at the ElementIntersectsSolidFilter problem and solution and tried ElementIntersectsElementFilter and ElementIntersectsSolidFilter.

Those filters do not return the expected result for me to deduce the voids in the floor either; in fact, they say that no elements intersect.

First case – area = 607.558m2 and Volume = 243.023m3:

Void instances cutting floor

Second case – area = 607.558m2 and Volume = 243.023m3:

Void instances cutting floor

Family parameter “Cut with Voids When Loaded”:

Void instances cutting floor

FamilyInstance cutting host:

Void instances cutting floor

Here is the code I use:

  Solid solid = floor.get_Geometrynew Options() )
    .OfType<Solid>()
    .Where<Solid>( s => (null != s) && (!s.Edges.IsEmpty) )
    .FirstOrDefault();

  FilteredElementCollector intersectingInstances 
    = new FilteredElementCollector( doc )
      .OfClasstypeofFamilyInstance ) )
      .WherePassesnew ElementIntersectsSolidFilter
        solid ) );

  int n1 = intersectingInstances.Count<Element>();

  intersectingInstances 
    = new FilteredElementCollector( doc )
      .OfClasstypeofFamilyInstance ) )
      .WherePassesnew ElementIntersectsElementFilter
        floor ) );

  int n = intersectingInstances.Count<Element>();

Here, both n and n1 are equal to 0.

Answer: Try using the HostObject FindInserts method instead:

  HostObject floor;
  List<ElementId> intersectingInstanceIds 
    = floor.FindInsertsfalsefalsefalsetrue )
      .ToList();

Response: I have done some tests and here are my results:

Void instances cutting floor

Situation:

  • Fl_1 is hosted by Level 3 and intersects the floor.
  • Fl_2 is hosted by the floor and intersects it.

Results:

  1. Do not cut geometry:
    • InstanceVoidCutUtils.GetCuttingVoidInstances(floor) returns void
    • floor.FindInserts(false,false,false,true) returns Fl_2
  2. Cut geometry:
    • InstanceVoidCutUtils.GetCuttingVoidInstances(floor) returns Fl_1
    • floor.FindInserts(false,false,false,true) returns both Fl_1 and Fl_2

In summary, FindInserts returns FI_1 even if its host (Level 3) is not the floor.

It’s good.

I think we can say that the problem is solved.

Thank you FAIR59 ;)