- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Alot of guides i have followed were not successful
``` printing views 1
private void button33_Click(object sender, EventArgs e) // It doesnt work
{
// Get the current Revit document and active view
UIDocument uidoc = uiapp2.ActiveUIDocument;
Autodesk.Revit.DB.Document doc = uidoc.Document;
Autodesk.Revit.DB.View activeView = uidoc.ActiveView;
// Create a new viewport for each angle
List<Viewport> newViewports = new List<Viewport>();
FilteredElementCollector collector = new FilteredElementCollector(doc, activeView.Id);
ICollection<ElementId> viewportIds = collector.OfCategory(BuiltInCategory.OST_Viewports).ToElementIds();
foreach (ElementId viewportId in viewportIds)
{
Viewport viewport = doc.GetElement(viewportId) as Viewport;
if (viewport != null)
{
```
```
for (int i = 0; i < 360; i += 10)
{
Viewport newViewport = Viewport.Create(doc, activeView.Id, viewport.ViewId, viewport.GetBoxCenter());
XYZ direction = new XYZ(Math.Sin(i * Math.PI / 180), 0, Math.Cos(i * Math.PI / 180));
newViewport.SetBoxCenter(viewport.GetBoxCenter() + direction * 10); // Adjust the distance as needed
newViewports.Add(newViewport);
}
}
}
// Extract an image from each new viewport
List<Image> images = new List<Image>();
foreach (Viewport newViewport in newViewports)
{
using (Transaction tx = new Transaction(doc, "Capture Image"))
{
tx.Start();
// Set the active view to the new viewport
uidoc.ActiveView = doc.GetElement(newViewport.ViewId) as Autodesk.Revit.DB.View;
// Export the image
ImageExportOptions options = new ImageExportOptions();
options.ZoomType = ZoomFitType.FitToPage;
options.PixelSize = 300; // Adjust the pixel size as needed
options.FilePath = "C:\\Users\\Public\\Downloads\\RevitImages\\image"; // Specify the file path without extension
options.HLRandWFViewsFileType = ImageFileType.PNG;
doc.ExportImage(options);
tx.Commit();
}
}
// Close the new viewports
foreach (Viewport newViewport in newViewports)
{
doc.Delete(newViewport.Id);
}
MessageBox.Show("Images extracted successfully!");
}
```
this produces no images help
Solved! Go to Solution.