Message 1 of 11
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi all,
I have questions about bounding box. I tried to get outline of BoundingBox and retrieve elements inside it. But I've faced 3 cases:
1. My code works fine with horizontal BoundingBox (rorate = 0 deg).
2. BoundingBox still can get outline, but can not select all element inside. (rorate = 10 ~ 20 deg).
3. BoundingBox can't get outline(rorate > 45 deg) .Error message is "outline is an empty outline".See code below in red line
[Transaction(TransactionMode.Manual)]
public class ElementInsideBoundingBox : IExternalCommand
{
public Result Execute(
ExternalCommandData commandData,
ref string message,
ElementSet elements)
{
UIApplication uiapp = commandData.Application;
UIDocument uidoc = uiapp.ActiveUIDocument;
Application app = uiapp.Application;
Document doc = uidoc.Document;
View3D curView3d = doc.ActiveView as View3D;
BoundingBoxXYZ box = curView3d.GetSectionBox();
Transform t = box.Transform;
Outline o = new Outline(t.OfPoint(box.Min), t.OfPoint(box.Max));
FilteredElementCollector collector = new FilteredElementCollector(doc);
BoundingBoxIsInsideFilter bbfilter = new BoundingBoxIsInsideFilter(o);
IList<ElementId> insideList = collector
.WhereElementIsNotElementType()
.WherePasses(bbfilter)
.Where(x => x.GetTypeId().IntegerValue != -1)
.Where(x => x.IsPhysicalElement())
.Select(x => x.Id)
.ToList();
uidoc.Selection.SetElementIds(insideList);
return Result.Succeeded;
}
}I attached revit file for example. Please tell me where I was wrong?
Thank you in advanced!
Solved! Go to Solution.