How to capture image for specific element using revit api?

How to capture image for specific element using revit api?

prasannamurumkar
Advocate Advocate
2,030 Views
3 Replies
Message 1 of 4

How to capture image for specific element using revit api?

prasannamurumkar
Advocate
Advocate

Hi 

i want to take image of  specific element which is zoom.

able to zoom by below:

UIApp.ActiveUIDocument.ShowElements(oEid);

 

And getting image of document by below:

using (Transaction tx = new Transaction(UIApp.ActiveUIDocument.Document))
{
tx.Start("Export Image");

string desktop_path = Environment.GetFolderPath(
Environment.SpecialFolder.Desktop);

Autodesk.Revit.DB.View view = UIApp.ActiveUIDocument.Document.ActiveView;

string filepath = Path.Combine(desktop_path,
view.Name);

ImageExportOptions img = new ImageExportOptions();
img.ZoomType = ZoomFitType.Zoom;
img.PixelSize = 96;
img.ImageResolution = ImageResolution.DPI_600;
img.FitDirection = FitDirectionType.Horizontal;
img.ExportRange = ExportRange.CurrentView;
img.HLRandWFViewsFileType = ImageFileType.PNG;
img.FilePath = filepath;
img.ShadowViewsFileType = ImageFileType.PNG;
UIApp.ActiveUIDocument.Document.ExportImage(img);
filepath = Path.ChangeExtension(filepath, "png");
Process.Start(filepath);
tx.Commit();


}

 

By this getting image of all element present in that specific view.As below image.

T01 - 5TH FLOOR.png

 

want to get  image of specific zoom element how could i get that?

 

 

 

(code for image copied from forum where jeremy has answered for one of query.)

0 Likes
Accepted solutions (1)
2,031 Views
3 Replies
Replies (3)
Message 2 of 4

jeremytammik
Autodesk
Autodesk

Create a new view displaying only the element you wish to see:

 

https://github.com/jeremytammik/GetElementImage

 



Jeremy Tammik
Developer Technical Services
Autodesk Developer Network, ADN Open
The Building Coder

Message 3 of 4

prasannamurumkar
Advocate
Advocate

thank you.

0 Likes
Message 4 of 4

TripleM-Dev.net
Advisor
Advisor
Accepted solution

Or:

A. isolate element in view + Zoom to Fit

B. calculate position of element (boundingbox) + Zoom to those coordinates

 

And then export with:  ExportRange = VisibleRegionOfCurrentView

 

see:

ZoomToFit Method 

ZoomAndCenterRectangle Method