public void changeFamiliesNames(Document doc) { //Gets the families Family familyNames = null; FilteredElementCollector collector = new FilteredElementCollector(doc); ICollection<Element> collection = collector.OfClass(typeof(Family)).ToElements(); ValueDictionary dictionaryList = new ValueDictionary(); var dictionary = dictionaryList.GetRenameFamilies(); using (Transaction t = new Transaction(doc)) { t.Start("new name"); foreach (Element e in collection) { familyNames = e as Family; string familyName = familyNames.Name; //Checks the dictionary and if found renames the family if (dictionary.ContainsKey(familyName)) { string value = dictionary[familyName]; familyNames.Name = value; count++; } } t.Commit(); string message = "Number of Families Renamed: "; MessageBox.Show(message + count.ToString()); } }
public void changeFamiliesNames(Document doc) { //Gets the families Family familyNames = null; FilteredElementCollector collector = new FilteredElementCollector(doc); ICollection <Element> collection = collector.OfClass(typeof(Family)).ToElements(); ValueDictionary dictionaryList = new ValueDictionary(); var dictionary = dictionaryList.GetRenameFamilies(); using (Transaction t = new Transaction(doc)) { t.Start("new name"); foreach (Element e in collection) { familyNames = e as Family; string familyName = familyNames.Name; //Checks the dictionary and if found renames the family if (dictionary.ContainsKey(familyName)) { string value = dictionary[familyName]; familyNames.Name = value; count++; } } t.Commit(); string message = "Number of Families Renamed: "; MessageBox.Show(message + count.ToString()); } }