Revit API Forum
Welcome to Autodesk’s Revit API Forums. Share your knowledge, ask questions, and explore popular Revit API topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Dupliate Views across Documents - problem with duplicated Views

1 REPLY 1
SOLVED
Reply
Message 1 of 2
Anonymous
396 Views, 1 Reply

Dupliate Views across Documents - problem with duplicated Views

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 

1 REPLY 1
Message 2 of 2
Sean_Page
in reply to: Anonymous

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...

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Forma Design Contest


Rail Community