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: 

Duplicating Sheet, sheet titleblock and 3D Viewports and ViewPort Elements with details from a project template to an existing project document

1 REPLY 1
SOLVED
Reply
Message 1 of 2
philbugmen
170 Views, 1 Reply

Duplicating Sheet, sheet titleblock and 3D Viewports and ViewPort Elements with details from a project template to an existing project document

I have a Project Template (.rte) and a Project Document (.rvt). I want to transfer the entire sheet, viewports, titleblock, model elements all on an active View or ViewSheet from the Template to the current project to exactly the same place.  I know there is this method available....

public static ICollection<ElementId> CopyElements(
	Document sourceDocument,
	ICollection<ElementId> elementsToCopy,
	Document destinationDocument,
	Transform transform,
	CopyPasteOptions options
)

I have also found ElementUtilities.Copy() and there are other methods where you can switch active views and paste elements. My question is do I need todo this atomically, by writing collectors and getting individual ElementId collections for each Class of revit element, legends, viewports, details within viewports, titleblock, schedules etc. Or is there a grab everything from an active ViewSheet method or technique?  I also Found new additions to Revit API 2022.1 I think...DuplicateSheetWithViewsAndDetailing(), does this method return elementids that I can then pass to the copyElements method or is this prohibited? If so I guess I could move everything but the 3d model elements and families.

Labels (6)
1 REPLY 1
Message 2 of 2
harrymattison
in reply to: philbugmen

There is no "grab everything" method. You will need to use some combination of...

 

ViewSheet.GetAllPlacedViews -  Returns the ElementIds of Views placed on this sheet. For each of these views, you will need to use a FilteredElementCollector to find the elements in that view. 

See https://thebuildingcoder.typepad.com/blog/2017/05/retrieving-elements-visible-in-view.html for more info, eso the comment that you will need a Custom Exporter if you want to find elements in linked models

 

Use ScheduleSheetInstance.OwnerViewId to find the sheet on which a schedule is placed
 
Get the titleblock, detail items, etc on the sheet using a FilteredElementCollector and the Element.OwnerViewId property
 

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

Post to forums  

Forma Design Contest


Rail Community