- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I am working to copy a Legend from a linked Document to the Current Document, but when I copy the View, and then try to copy the elements, it is creating the Legend twice with an incremental number, and the second Legend (Legend1) contains the copied elements, but the first does not.
I then tried to use a Legend already in the current document and Copy the linked elements into it, but it creates a new Legend with the elements in it, but does nothing in the existing legend.
Here is the code I am using:
if (new FilteredElementCollector(doc).OfClass(typeof(View)).Cast<View>().Where(x => x.ViewType == ViewType.Legend).FirstOrDefault() is View tempLegend) { using (Transaction trans = new Transaction(doc)) { trans.Start("Copy Legends"); foreach (ListViewItem item in lsvLegends.CheckedItems) { View view = (View)item.Tag; ICollection<ElementId> elemIds = new FilteredElementCollector(linkDoc, view.Id).ToElementIds(); ElementTransformUtils.CopyElements(view, elemIds, tempLegend, Transform.Identity, options); count++; } trans.Commit(); } MessageBox.Show("Copied " + count + " Legends"); DialogResult = DialogResult.OK; Close(); }
The result of this should be the existing Legend (view) with the Copied elements in it from the Linked document. The actual result is the existing Legend is untouched, and a new Legend with the Name of the linked Legend containing all of the elements in it. Now, this is actually what I want, but doesn't work as it says it should.
Solved! Go to Solution.