Has anyone got any code to get the length of a wall? Currently I use:
ElementCategoryFilter wallsFilter =
new ElementCategoryFilter(BuiltInCategory.OST_Walls);
FilteredElementCollector collector = new FilteredElementCollector(Doc);
IList<Element> walls =
collector.WherePasses(wallsFilter).WhereElementIsNotElementType().ToElements();
foreach (Element wall in walls)
MessageBox.Show(wall.get_Parameter("Length").AsString());
Length comes back empty!!!
AsString()
assumes that the parameter is of string type (Parameter.StorageType == StorageType.String)
. This length parameter is a double length measurement. So AsDouble()
should work. Or you can use AsValueString()
to convert the value to a string with units as would be seen in the UI.
You could also switch to use BuiltInParameter.CURVE_ELEM_LENGTH
instead of "Length"
as a string. This would be useful if the application is to be localized.