private static bool DuplicateReferenceCallouts(View fromView, View toView) { bool result = false; try { Document fromDoc = fromView.Document; Document toDoc = toView.Document; CopyPasteOptions copyPasteOptions = new CopyPasteOptions(); copyPasteOptions.SetDuplicateTypeNamesHandler(new HideAndAcceptDuplicateTypeNamesHandler()); ICollection <ElementId> referenceCalloutIds = fromView.GetReferenceCallouts(); if (referenceCalloutIds.Count > 0) { foreach (ElementId eId in referenceCalloutIds) { XYZ firstPoint = null; XYZ secondPoint = null; bool cornerFound = GetCalloutCornerPoints(fromDoc, eId, out firstPoint, out secondPoint); Element callout = fromDoc.GetElement(eId); if (null != callout) { using (Transaction trans = new Transaction(toDoc, "Duplicate Reference Callout")) { try { trans.Start(); toDoc.Regenerate(); FilteredElementCollector collector = new FilteredElementCollector(toDoc); List <ViewDrafting> views = collector.OfClass(typeof(ViewDrafting)).ToElements().Cast <ViewDrafting>().ToList(); var viewFound = from view in views where view.Name == callout.Name select view; if (viewFound.Count() > 0) { ViewDrafting referenceView = viewFound.First(); ViewSection.CreateReferenceCallout(toDoc, toView.Id, referenceView.Id, firstPoint, secondPoint); } trans.Commit(); } catch (Exception ex) { string message = ex.Message; trans.RollBack(); } } } } } } catch (Exception ex) { string message = ex.Message; //MessageBox.Show("Failed to duplicate reference callouts.\n"+ex.Message, "Duplicate Reference Callouts", MessageBoxButton.OK, MessageBoxImage.Warning); errorMessage.AppendLine(toView.Name + ": errors in duplicating reference callouts"); } return(result); }