Programmatically export image independent of viewport

Programmatically export image independent of viewport

lharwoodWZKMU
Contributor Contributor
989 Views
2 Replies
Message 1 of 3

Programmatically export image independent of viewport

lharwoodWZKMU
Contributor
Contributor

Right now in our plugin in order to get an image of the dwg we are first zooming extents and then using WMFOUT. This works fine but the fidelity decreases as drawings get bigger. From what I can tell WMFOUT only includes whatever is in the viewport. Is there any way to get an image out of AutoCAD that doesn't take the viewport into account? So what would be great is to be able to zoom in at a certain level and capture all selected entities whether they are in the viewport or not.

 

 

0 Likes
990 Views
2 Replies
Replies (2)
Message 2 of 3

norman.yuan
Mentor
Mentor

You can use APIs in Autodesk.AutoCAD.GraphcsSystem namespace to capture screenshot of AutoCAD model/screen. Kean Walmsley posted a few articles many years ago (in the earlier stage of AutoCAD .NET API) on this topic:

 

https://through-the-interface.typepad.com/through_the_interface/2007/04/rendering_autoc.html 

https://www.keanw.com/2007/04/taking_a_snapsh.html 

https://www.keanw.com/2007/04/taking_a_snapsh_1.html 

 

With latest AutoCAD, there might be some API changes over the years (I am not certain on this).

 

The other way, which might be simpler and more common, is to simply plot the needed content with image PC3, such as XXXXPng.pc3, XXXXXJpg.pc3, or even xxxxPDF.pc3, which all come with AutoCAD. By plotting, you can the drawing content to be plotted: Layout, Extents, Window (with Window option, obviously you can zoom in/out as needed), you can plot to different style (B&W, or color, different lineweight...). With APIs in Autodesk.AutoCAD.PlottingServices namespace, you can easily control the plotting process, or do batch plotting.

Norman Yuan

Drive CAD With Code

EESignature

0 Likes
Message 3 of 3

lharwoodWZKMU
Contributor
Contributor

Thank you for your response. At first glance it looks like those options wouldn't support creating a wmf or emf, is that correct? We may be able to get by using a png but I'll have to play around with it.