Revit API Forum
Welcome to Autodesk’s Revit API Forums. Share your knowledge, ask questions, and explore popular Revit API topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Collect detail items inside crop region

3 REPLIES 3
SOLVED
Reply
Message 1 of 4
mr.engineer.aec
212 Views, 3 Replies

Collect detail items inside crop region

 Hi mate,

 I have many detail items outside crop region.

 But i only want to select detail items inside crop region.

 I use code like this but it collect both inside and outside detail items.

 What can i do ?

 Thank in advanced !

 

            List<FamilyInstance> symbols = new FilteredElementCollector(doc, doc.ActiveView.Id)
                .OfClass(typeof(FamilyInstance))
                .WhereElementIsNotElementType()
                .Where(x => x.Category.Name == "Detail Items")
                .Where(x => x.IsHidden(doc.ActiveView) == false)
                .Cast<FamilyInstance>()
                .ToList();

 

mrengineeraec_1-1655890605709.png

 

 

3 REPLIES 3
Message 2 of 4

Hi @mr.engineer.aec ,

 

One solution is to get the bounding box from the crop box and create a BoundingBoxIntersectsFilter.

if(doc.ActiveView.CropBoxVisible && doc.ActiveView.CropBoxActive)
                  {
                      BoundingBoxXYZ bb = doc.ActiveView.CropBox;
                      Outline myOutLn = new Outline(bb.Min, bb.Max);
                      BoundingBoxIntersectsFilter filter = new BoundingBoxIntersectsFilter(myOutLn);                    
                  } 

Now use this BoundingBoxIntersectsFilter along with other filters in FilteredElementCollector to get the required elements.

Could you please try this suggestion and let me know?


Naveen Kumar T
Developer Technical Services
Autodesk Developer Network

Message 3 of 4

 Thank @naveen.kumar.t for reply,

 I think if use boundingbox it'll collect detail items like this so,

 I want to collect only inside mate.

mrengineeraec_0-1655949058676.png

 

Message 4 of 4

Hi @mr.engineer.aec ,

 

Could you please try using BoundingBoxIsInsideFilter.

https://www.revitapidocs.com/2023/eb8735d7-28fc-379d-9de9-1e02326851f5.htm 

 


Naveen Kumar T
Developer Technical Services
Autodesk Developer Network

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Customer Advisory Groups


Rail Community