Quantcast
Channel: All Revit API Forum posts
Viewing all articles
Browse latest Browse all 67020

Re: C# How to select bar of Rebar

$
0
0

Hi @huynguyen96str 

 

   You have to use FilteredElementCollector. Kindly check the below code snippet for additional reference 

 

 

public void FilterRebarAndSetSelection(UIDocument uidoc) { // Get the Revit Document Document doc = uidoc.Document; // Create a FilteredElementCollector to collect all Rebar elements FilteredElementCollector collector = new FilteredElementCollector(doc); // Filter only Rebar elements ICollection<Element> rebarElements = collector .OfClass(typeof(Rebar)) .ToElements(); // Convert the rebar elements to a list of ElementIds List<ElementId> rebarElementIds = rebarElements.Select(e => e.Id).ToList(); // Set the current selection to the Rebar elements uidoc.Selection.SetElementIds(rebarElementIds); }

 

call the method inside the Execute Function.

 

Hope this will helps 🙂

 


Viewing all articles
Browse latest Browse all 67020

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>