I'm having difficulty trying to filter out my walls by a specific name (which works) and by the walls' base constraint to equal the associated level of my active view. This is the code I currently have. The Build is successful but doesn't do anything when I execute the macro. I believe the issue is within the reading the string. Thank you in advance for the help.
Document doc = this.Application.ActiveUIDocument.Document; View myActiveView = doc.ActiveView; Parameter level = myActiveView.LookupParameter("Associated Level"); String levelName = level.AsString(); FilteredElementCollector swwallfilter = new FilteredElementCollector(doc, myActiveView.Id); List<Element>swwalls = swwallfilter.OfCategory(BuiltInCategory.OST_Walls).ToList(); var swtypeelements = from element in swwallfilter where element.Name.Contains("Shear Wall") && element.get_Parameter(BuiltInParameter.WALL_BASE_CONSTRAINT).Equals(levelName) select element;
Solved! Go to Solution.
Solved by FAIR59. Go to Solution.
I guess this doesn't go by name (string) but rather the level you are looking for.
BuiltInParameter.WALL_BASE_CONSTRAINT
should work by Id.
Please correct me if I am wrong, didn't try.
Christian
element.get_Parameter(BuiltInParameter.WALL_BASE_C
so try
element.get_Parameter(BuiltInParameter.WALL_BASE_C
List<Wall> wallCollector = new List<Wall>();
string level= form1.Mylevel;
ElementCategoryFilter filter = new ElementCategoryFilter(BuiltInCategory.OST_Walls);
FilteredElementCollector collector = new FilteredElementCollector(doc);
IList<Element> walls = collector.WherePasses(filter).WhereElementIsNotElementType().ToElements();
foreach (Element e in walls)
{
string basconstraint = e.get_Parameter(BuiltInParameter.WALL_BASE_CONSTRAINT).AsValueString();
if (basconstraint == level)
{
wallCollector.Add(e as Wall);
}
}
I think this is also useful for the Filtering Walls by Base Constraint