Message 1 of 5

Not applicable
02-14-2020
02:20 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hey,
I am using the following code to copy a schedules/quantities element from on document to another.
private static ICollection<ElementId> DuplicateSchedules(Document from, IEnumerable<ViewSchedule> schedules, Document to) { var ids = schedules.AsEnumerable<View>().ToList<View>().ConvertAll<ElementId>(v => v.Id); return DuplicateElementsAccrossDocuments(from, ids, to); } private static ICollection<ElementId> DuplicateElementsAccrossDocuments(Document from, ICollection<ElementId> ids, Document to) { ICollection<ElementId> copies = null; using (var transaction = new Transaction(to, "Duplicate Elements")) { if (transaction.Start() == TransactionStatus.Started) { // Use destination types if duplicates found var options = new CopyPasteOptions(); options.SetDuplicateTypeNamesHandler(new HideAndAcceptDuplicateTypeNamesHandler()); copies = ElementTransformUtils.CopyElements(from, ids, to, Transform.Identity, options); // Delete cannot copy duplicates warning var failureOptions = transaction.GetFailureHandlingOptions(); failureOptions.SetFailuresPreprocessor(new HidePasteDuplicationTypesPreprocessor()); transaction.Commit(); } } return copies; }
It works, but the copied schedule is placed under a ??? category.
The category can be changed manually by editing Projectbrowser -> Constraints.
Sadly I wasn't able to find a way to do this in the API. Is that even possible?
Solved! Go to Solution.