因为版本问题
原:
foreach(Element elem in selections.Elements)
{
}
现:
ElementSet selections = new ElementSet();
foreach (ElementId elementId in commandData.Application.ActiveUIDocument.Selection.GetElementIds())
{
selections.Insert(commandData.Application.ActiveUIDocument.Document.GetElement(elementId));
}
foreach (Element elem in selections)
{
}