Dupliate Views across Documents - problem with duplicated Views

Dupliate Views across Documents - problem with duplicated Views

Anonymous
Not applicable
499 Views
1 Reply
Message 1 of 2

Dupliate Views across Documents - problem with duplicated Views

Anonymous
Not applicable

Hi guys,

I managed to copy views from one Document to another, with all the annotation content on the view - however, as a result I get 2 views in destination Document (one with annotation, one without). Any hints, how to get only one with annotation?

 

 

 

foreach(T view in AllViews)
{
	IList<ElementId> copyIds = new List<ElementId>();
	copyIds.Add(view.Id);    
				
// put view-specific elements on the view in the copyIdsViewSpecific collection
	IList<ElementId> copyIdsViewSpecific = new List<ElementId>();
	foreach (Element e in new FilteredElementCollector(doc).OwnedByView(view.Id))
	{
		// viewports and sunandshadowsettings cannot be copied
		if (!(e is Viewport) && !(e is SunAndShadowSettings))
			copyIdsViewSpecific.Add(e.Id);  
	}
				    
	Transaction t = new Transaction(otherDoc, "Copy View");					
	t.Start();

	ICollection<ElementId> copiedElements = ElementTransformUtils.CopyElements(doc, copyIds, otherDoc, Transform.Identity, new CopyPasteOptions());
	T newView = otherDoc.GetElement(copiedElements.First()) as T;

	ElementTransformUtils.CopyElements(view, copyIdsViewSpecific, newView, Transform.Identity, new CopyPasteOptions());

	t.Commit();
}

 

 

, how to 

0 Likes
Accepted solutions (1)
500 Views
1 Reply
Reply (1)
Message 2 of 2

Sean_Page
Collaborator
Collaborator
Accepted solution

Check this post, I think you'll find the item marked as answer contains the answer your looking for.

 

https://forums.autodesk.com/t5/revit-api-forum/elementtransformutils-copy-legend-from-linked-documen...

Sean Page, AIA, NCARB, LEED AP
Partner, Computational Designer, Architect