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.
Solved! Go to Solution.
Solved by harrymattison. Go to Solution.
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
Can't find what you're looking for? Ask the community or share your knowledge.