Any ZoomExtents() method will most-likely not work in RealDwg.
I'm not sure if Database.UpdateExt() will work in RealDwg, but if it does then you would call it, and then read the Database's Extmin and Extmax properties to get the extents rectangle.
If UpdateExt() doesn't work in RealDwg, the only other way to calculate the extents is by iterating over the objects in the space shown in the view, and unioning each of their GeometricExtents together (e.g., Create a new Extents3d instance, and then repeatedly use it's AddExtents() method to add the GeometricExtents of each entity in the space).
So, if your view is in model space, you have to create a new ViewportTableRecord, and then compute the extents rectangle using either means described above, and set the center and height properties of the ViewportTableRecord to the center and height of the calculated extents rectangle.
@MattKincaid wrote:
Thanks ActivistInvestor. That sort of gets at what I'm trying to do.
The issue is that I'm developing this as a RealDWG app (i.e. no instance of AutoCad is opened). The goal is to have ZoomExtents already done the next time someone opens the file in Acad (as the OP is also trying to do). In this state, it appears the ViewPortTable is empty for newly created DWGs.
So is the correct strategy something like as follows?
1. Create a new ViewPortTableRecord
2. Add that record to the ViewPortTable.
3. Then what? The ViewPortTableRecord class doesn't have a ZoomExtents method. Is there a way to cast a ViewPortTableRecord as a View?
Many thanks!