SELECTING ELEMENTS CUT BY ACTIVE VIEW PLANE RETURNS NOTHING

SELECTING ELEMENTS CUT BY ACTIVE VIEW PLANE RETURNS NOTHING

AGYEMANG.OFOSU
Advocate Advocate
970 Views
4 Replies
Message 1 of 5

SELECTING ELEMENTS CUT BY ACTIVE VIEW PLANE RETURNS NOTHING

AGYEMANG.OFOSU
Advocate
Advocate

I have an issue selecting beams that are cut by the view plane. Unfortunately the code returns nothing. 

 

public void Show()
		{
			UIDocument uidoc = this.ActiveUIDocument;
			Document doc = uidoc.Document;
			
			
			BoundingBoxXYZ box = doc.ActiveView.CropBox;		
			Outline outline = new Outline(box.Min, box.Max);		
					
			BoundingBoxIntersectsFilter beamintersect = new BoundingBoxIntersectsFilter(outline);	
			List<Element> beams = new FilteredElementCollector(doc, doc.ActiveView.Id).OfCategory(BuiltInCategory.OST_StructuralFraming).WherePasses(beamintersect).WhereElementIsNotElementType().ToElements().ToList();


			ICollection<ElementId> idc = new List<ElementId>();
			
			foreach (var element in beams) 
			{
				ElementId id = element.Id;
				idc.Add(id);
				
			}
			
			uidoc.Selection.SetElementIds(idc);
			uidoc.ShowElements(idc);

 

 

0 Likes
Accepted solutions (1)
971 Views
4 Replies
Replies (4)
Message 2 of 5

naveen.kumar.t
Autodesk Support
Autodesk Support

Hi @AGYEMANG.OFOSU,

I tried using your code and it works fine for me.

The problem may be with your bounding box.

Just increase the boundary of your bounding box and give it a try.


Naveen Kumar T
Developer Technical Services
Autodesk Developer Network

0 Likes
Message 3 of 5

AGYEMANG.OFOSU
Advocate
Advocate

it does not work. I am trying to get beams parallel to the view direction and are cut by the view plane but it does not work. I have tried 

0 Likes
Message 4 of 5

FAIR59
Advisor
Advisor
Accepted solution
0 Likes
Message 5 of 5

AGYEMANG.OFOSU
Advocate
Advocate

Thankfully I had seen your solution before and it worked liked a charm. Grateful. 

0 Likes