public static void SelectAllNotes(UIDocument uiDoc) { Document currentDoc = uiDoc.Document; Selection Sel = uiDoc.Selection; ElementId v = uiDoc.ActiveView.Id; ISelectionFilter selectionFilter = new TextSelectionFilter(); Reference ChangedObject = Sel.PickObject(ObjectType.Element, selectionFilter); TextNote ChangedElement = currentDoc.GetElement(ChangedObject.ElementId) as TextNote; FilteredElementCollector TextCollector = new FilteredElementCollector(currentDoc, v); ICollection <ElementId> notes = TextCollector.OfCategory(BuiltInCategory.OST_TextNotes).ToElementIds().ToList(); List <ElementId> notelist = new List <ElementId>(); foreach (ElementId eid in notes) { TextNote tn = currentDoc.GetElement(eid) as TextNote; if (tn.TextNoteType.Name == ChangedElement.TextNoteType.Name) { notelist.Add(eid); } } Sel.SetElementIds(notelist); }
public static void EditTextStyles(UIDocument uiDoc) { Document currentDoc = uiDoc.Document; Selection sel = uiDoc.Selection; ISelectionFilter selectionFilter = new TextSelectionFilter(); Reference ChangedObject = sel.PickObject(ObjectType.Element, selectionFilter); TextNote ChangedElement = currentDoc.GetElement(ChangedObject.ElementId) as TextNote; Reference NewObject = sel.PickObject(ObjectType.Element, selectionFilter); TextNote NewElement = currentDoc.GetElement(NewObject.ElementId) as TextNote; TextNoteType type = NewElement.TextNoteType; TextNoteType oldType = ChangedElement.TextNoteType; FilteredElementCollector TextCollector = new FilteredElementCollector(currentDoc); List <ElementId> Notes = TextCollector.OfCategory(BuiltInCategory.OST_TextNotes).ToElementIds().ToList(); foreach (ElementId EID in Notes) { TextNote TN = currentDoc.GetElement(EID) as TextNote; if (TN.TextNoteType.Name == oldType.Name) { if (TN.GroupId == ElementId.InvalidElementId) { TN.TextNoteType = type; } else { Group group = currentDoc.GetElement(TN.GroupId) as Group; } } } currentDoc.Delete(oldType.Id); }