Revit API allows you to find elements that pass through rays. The method is fixed mode, so there is nothing to say.
Key code: [TransactionAttribute (Autodesk. Revit. Attributes. TransactionMode. Manual)]
FindSupporting: IExternalCommand
{
Result Execute (ExternalCommandData commandData, messages, ElementSet elements)
{
UIApplication app = commandData. Application;
Document doc = app. ActiveUIDocument. Document;
Transaction trans = Transaction (doc ,);
Trans. Start ();
Selection sel = app. ActiveUIDocument. Selection;
Reference ref1 = sel. PickObject (ObjectType. Element ,);
Duct duct = doc. GetElement (ref1) Duct;
LocationCurve lc = duct. Location LocationCurve;
Curve curve = lc. Curve;
XYZ ptStart = curve. get_EndPoint ();
XYZ ptEnd = curve. get_EndPoint ();
XYZ offset = XYZ (,); ptStart = ptStart-offset;
PtEnd = ptEnd-offset;
View3D view3d =;
View3d = doc. ActiveView View3D;
(View3d =)
{
TaskDialog. Show (,);
Result. Failed;
}
BeamLen = curve. Length;
IList <ReferenceWithContext> references = doc. FindReferencesWithContextByDirection (ptStart, (ptEnd-ptStart), view3d );
Sel. Elements. Clear ();
Tolerate =;
(ReferenceWithContext reference references)
{
Reference ref2 = reference. GetReference (); ElementId id = ref2.ElementId;
Element elem = doc. get_Element (id );
(Elem Wall)
{
(Reference. Proximity <(beamLen + tolerate )){
Sel. Elements. Add (elem );
}
}
}
Trans. Commit ();
Result. Succeeded;
}
} Url: http://greatverve.cnblogs.com/p/FindReferencesWithContextByDirection.html