Exporting Image from View (Zoomed to Bounding Box)

Exporting Image from View (Zoomed to Bounding Box)

Anonymous
Not applicable
1,187 Views
2 Replies
Message 1 of 3

Exporting Image from View (Zoomed to Bounding Box)

Anonymous
Not applicable

 Hello All,

             Is there any way to use Document.ExportImage() but only export an image that is zoomed to a bounding box around an object? I'm trying to export images from a DraftingView, but there seems to be no way to zoom the image to a bounding box around a single object on the DraftingView before generating the image. Any help would be greatly appreciated.

          Thank You,

                  James Kerfoot 

0 Likes
1,188 Views
2 Replies
Replies (2)
Message 2 of 3

jeremytammik
Autodesk
Autodesk

Dear James,

 

Thank you for your query.

 

I see two possible approaches to achieve this:

 

  • Use ExportImage; this requires you to set up the view appropriately, so it displays only the desired object
  • Use a generic .NET library to make a screen snapshot of a partial Revit view; you could use the UIView class to determine the Windows screen coordinates, i.e., pixels, to capture.

 

I suggest you go for the former approach and take a look at some of the discussions in The Building Coder topic group on setting up a 3D view:

 

https://thebuildingcoder.typepad.com/blog/about-the-author.html#5.37

 

Several of them deal with exporting individual elements to specific file formats.

 

You could use a similar approach to isolate and zoom to an element in a given view before exporting that.

 

This post shows how to set up a section view to display a single element:

 

https://thebuildingcoder.typepad.com/blog/2012/06/create-section-view-parallel-to-wall.html

 

If you also isolate the element, it should give you just what you need.

 

I hope this helps.

 

Best regards,

 

Jeremy

 



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

0 Likes
Message 3 of 3

BenoitE&A
Collaborator
Collaborator

Hi James,

Just falling on your post from another and fun !! I've been working on this the last month.

Yes you can use Document.ExportImage() to create images of a Cropped View. 

You can easily determine the CropRegion using yourObject.get_BoundingBox(yourView) and expand it if it does not please you.

Then you can apply this CropRegion to your view (view.CropBox = myBoundingBox).

And Export the view using ExportRange.CurrentView.

Benoit


Benoit FAVRE
CEO of etudes & automates
www.etudesetautomates.com/
0 Likes