Is the Host property set at all?
I don't know.
Have you checked that?
Have you installed and used RevitLookup?
What I meant was to use a solid intersection filter, cf. GetInstancesIntersectingElement:
https://github.com/jeremytammik/the_building_coder_samples/blob/master/BuildingCoder/BuildingCoder/C...
#region Retrieve family instances intersecting BIM element
/// <summary>
/// Retrieve all family instances intersecting a
/// given BIM element, e.g. all columns
/// intersecting a wall.
/// </summary>
void GetInstancesIntersectingElement( Element e )
{
Document doc = e.Document;
Solid solid = e.get_Geometry( new Options() )
.OfType<Solid>()
.Where<Solid>( s => null != s && !s.Edges.IsEmpty )
.FirstOrDefault();
FilteredElementCollector intersectingInstances
= new FilteredElementCollector( doc )
.OfClass( typeof( FamilyInstance ) )
.WherePasses( new ElementIntersectsSolidFilter(
solid ) );
int n1 = intersectingInstances.Count<Element>();
intersectingInstances
= new FilteredElementCollector( doc )
.OfClass( typeof( FamilyInstance ) )
.WherePasses( new ElementIntersectsElementFilter(
e ) );
int n = intersectingInstances.Count<Element>();
Debug.Assert( n.Equals( n1 ),
"expected solid intersection to equal element intersection" );
string result = string.Format(
"{0} family instance{1} intersect{2} the "
+ "selected element {3}{4}",
n, Util.PluralSuffix( n ),
( 1 == n ? "s" : "" ),
Util.ElementDescription( e ),
Util.DotOrColon( n ) );
string id_list = 0 == n
? string.Empty
: string.Join( ", ",
intersectingInstances
.Select<Element, string>(
x => x.Id.IntegerValue.ToString() ) )
+ ".";
Util.InfoMsg2( result, id_list );
}
/// <summary>
/// Retrieve all beam family instances
/// intersecting two columns, cf.
/// http://forums.autodesk.com/t5/revit-api/check-to-see-if-beam-exists/m-p/6223562
/// </summary>
FilteredElementCollector
GetBeamsIntersectingTwoColumns(
Element column1,
Element column2 )
{
Document doc = column1.Document;
if( column2.Document.GetHashCode() != doc.GetHashCode() )
{
throw new ArgumentException(
"Expected two columns from same document." );
}
FilteredElementCollector intersectingStructuralFramingElements
= new FilteredElementCollector( doc )
.OfClass( typeof( FamilyInstance ) )
.OfCategory( BuiltInCategory.OST_StructuralFraming )
.WherePasses( new ElementIntersectsElementFilter( column1 ) )
.WherePasses( new ElementIntersectsElementFilter( column2 ) );
int n = intersectingStructuralFramingElements.Count<Element>();
string result = string.Format(
"{0} structural framing family instance{1} "
+ "intersect{2} the two beams{3}",
n, Util.PluralSuffix( n ),
( 1 == n ? "s" : "" ),
Util.DotOrColon( n ) );
string id_list = 0 == n
? string.Empty
: string.Join( ", ",
intersectingStructuralFramingElements
.Select<Element, string>(
x => x.Id.IntegerValue.ToString() ) )
+ ".";
Util.InfoMsg2( result, id_list );
return intersectingStructuralFramingElements;
}
#endregion // Retrieve family instances intersecting BIM element
Cheers,
Jeremy