Hi guys,
I tried to implement both ways on the code. One using ElementIntersectsElementFilter and ElementIntersectsSolidFilter. Only ElementIntersectsElementFilter worked for me while using a pre-created sphere family and instancing it on the point desired. However I feel that not having to work with Transactions might improve performance a bit.
Thank you @Omar_Amen for the idea.
@RPTHOMAS108 I think that there's something missing to get ElementIntersectsSolidFilter working.
Here's my code:
private Solid Sphere(XYZ center, double radius)
{
List<Curve> profile = new List<Curve>();
XYZ profilePlus = center + new XYZ(0, radius, 0);
XYZ profileMinus = center - new XYZ(0, radius, 0);
profile.Add(Line.CreateBound(profilePlus, profileMinus));
profile.Add(Arc.Create(profileMinus, profilePlus, center + new XYZ(radius, 0, 0)));
CurveLoop curveLoop = CurveLoop.Create(profile);
SolidOptions options = new SolidOptions(ElementId.InvalidElementId, ElementId.InvalidElementId);
Frame frame = new Frame(center, XYZ.BasisX, -XYZ.BasisZ, XYZ.BasisY);
if (Frame.CanDefineRevitGeometry(frame) == true)
{
Solid sphere = GeometryCreationUtilities.CreateRevolvedGeometry(frame, new CurveLoop[] { curveLoop }, 0, 2 * Math.PI, options);
return sphere;
}
return null;
}
private bool SphereCheck(Solid sphere, FamilyInstance fi)
{
ElementIntersectsSolidFilter intersect = new ElementIntersectsSolidFilter(sphere);
bool result = intersect.PassesFilter(fi);
return result;
}
I run first Sphere to get the solid using a LocationPoint from a FamilyInstance, then pass another FamilyInstance with the sphere Solid to check it's intersection.
Thanks guys