Simple example to reproduce:
- Revit version: 2023
- Project path: "C:\Program Files\Autodesk\Revit 2023\Samples\rac_basic_sample_project.rvt"
- Profiling tools: JetBrains Rider, dotMemory
Code:
var sectionType = new FilteredElementCollector(document)
.WhereElementIsElementType()
.OfClass(typeof(ViewFamilyType))
.Cast<ViewFamilyType>()
.First(x => x.ViewFamily == ViewFamily.Section);
var section = ViewSection.CreateSection(document, sectionType.Id, new BoundingBoxXYZ());
section.DisplayStyle = DisplayStyle.RealisticWithEdges;
var options = new ImageExportOptions
{
ZoomType = ZoomFitType.FitToPage,
ExportRange = ExportRange.SetOfViews,
FitDirection = FitDirectionType.Vertical,
PixelSize = 220,
ImageResolution = ImageResolution.DPI_150,
HLRandWFViewsFileType = ImageFileType.PNG,
ShadowViewsFileType = ImageFileType.PNG,
FilePath = Path.GetTempPath()
};
options.SetViewsAndSheets(new List<ElementId> {section.Id});
document.ExportImage(options);