显示图形范围和界限
 
 

The extents or limits of a drawing are used to define the boundary in which the outermost objects appear in or the area defined by the limits of the current space.

图形的范围是用于定义可将所有对象显示于其内的最接近的边界,图形的界限是用于定义当前空间界限的区域。

See “Magnify a View (Zoom)” in the AutoCAD User's Guide for illustrations of how zooming works.

有关如何进行缩放的图解,请参见《用户手册》中的“放大视图(缩放)”。

计算当前空间的范围

The extents of the current space can be accessed from the Database object using the following properties:

当前空间的范围可以使用下面的属性从 Database 对象中被访问:

Once the extents of the current space is obtained, you can calculate the new values for the Width and Height properties of the current view. The new width for the view is calculated using the following formula:

只要获得当前空间的范围,就可以为当前视图计算新的 WidthHeight 属性值。视图的新 width 值使用下面的公式计算:

dWidth = MaxPoint.X - MinPoint.X

The new height for the view is calculated using the following formula:

视图的新 height 值使用下面的公式计算:

dHeight = MaxPoint.Y - MinPoint.Y

After the width and height of the view are calculated, the center point of the view can be calculated. The center point of the view can be obtained using the following formula:

视图的宽度和高度计算后,就可以计算视图的中心点了。视图的中心点可以使用下面的公式获得:

dCenterX = (MaxPoint.X + MinPoint.X) * 0.5
dCenterY = (MaxPoint.Y + MinPoint.Y) * 0.5

计算当前空间的界限

To change the display of a drawing based on the limits of the current space, you use the Limmin and Limmax , and Plimmin and Plimmax properties of the Database object. After the points that define the limits of the current space are returned, you can use the previously mentioned formulas to calculate the width, height and center points of the new view.

若要改变以当前空间的界限为基础的图形显示,需要使用 Database 对象的 Limmin 和 Limmax 以及 Plimmin 和 Plimmax 属性。定义当前空间的界限的点返回后,用户可以使用前面提到的公式计算新视图的宽度、高度和中心点。

放大当前空间的范围和界限

This example code demonstrates how to display the extents of limits of the current space using the Zoom procedure defined under Manipulate the Current View.

本例代码演示如何使用 操作当前视图部分定义的 Zoom 过程显示当前空间的界限的范围。

While the Zoom procedure is passed a total of four values, the first two values passed should be the points that define the minimum and maximum points of the area to be displayed. The third value is defined as a new 3D point and is ignored by the procedure, while the last value is used to resize the image of the drawing so it is not completely fill the entire drawing window.

Zoom 过程总共需要传递四个参数,第一二个参数传递将要显示区域的最小和最大点。第三个值定义为新 3D 点并且在过程中是忽略的,最后一个值用于调整图像的大小,因此它不能完成铺满整个的图形窗口。

VB.NET

<CommandMethod("ZoomExtents")> _
Public Sub ZoomExtents()
  '' 缩放当前空间的范围  Zoom to the extents of the current space
  Zoom(New Point3d(), New Point3d(), New Point3d(), 1.01075)
End Sub
 
<CommandMethod("ZoomLimits")> _
Public Sub ZoomLimits()
  Dim acDoc As Document = Application.DocumentManager.MdiActiveDocument
  Dim acCurDb As Database = acDoc.Database
 
  '' 缩放模型空间的范围  Zoom to the limits of Model space
  Zoom(New Point3d(acCurDb.Limmin.X, acCurDb.Limmin.Y, 0), _
       New Point3d(acCurDb.Limmax.X, acCurDb.Limmax.Y, 0), _
       New Point3d(), 1)
End Sub

C#

[CommandMethod("ZoomExtents")]
static public void ZoomExtents()
{
  // 缩放当前空间的范围  Zoom to the extents of the current space
  Zoom(new Point3d(), new Point3d(), new Point3d(), 1.01075);
}
 
[CommandMethod("ZoomLimits")]
static public void ZoomLimits()
{
  Document acDoc = Application.DocumentManager.MdiActiveDocument;
  Database acCurDb = acDoc.Database;
 
  // 缩放模型空间的范围  Zoom to the limits of Model space
  Zoom(new Point3d(acCurDb.Limmin.X, acCurDb.Limmin.Y, 0),
       new Point3d(acCurDb.Limmax.X, acCurDb.Limmax.Y, 0),
       new Point3d(), 1);
}
VBA/ActiveX 代码参考