If you need to increase or decrease the magnification of the image in the drawing window, you change the Width and Height properties of the current view. When resizing a view, make sure to change the Width and Height properties by the same factor. The scale factor you calculate when resizing the current view will commonly be based on one of the following situations:
如果需要增加或减小图形窗口中图像的缩放比例,可以修改当前视图的宽度和高度属性。当调整视图的大小时,要保证通过相同的比例因子修改宽度和高度。调整当前视图大小时计算比例因子一般基于下面几种情况:
This example code demonstrates how to reduce the current view by 50% using the Zoom procedure defined under Manipulate the Current View.
本例代码演示如何使用 操作当前视图部分定义的 Zoom 过程缩小当前视图为原来的50%。
While the Zoom procedure is passed a total of four values, the first two are new 3D points which are not used. The third value passed is the center point to use in resizing the view and the last value passed is the scale factor to use in resizing the view.
虽然 Zoom 过程总共需要传递四个参数,然而第一二个参数是不需要使用的,只使用了新建的 3D 点。第三个参数传递用于视图调整大小的中心点,最后一个参数传递调整视图大小使用的缩放比例。
<CommandMethod("ZoomScale")> _
Public Sub ZoomScale()
'' 获得当前文档 Get the current document
Dim acDoc As Document = Application.DocumentManager.MdiActiveDocument
'' 获得当前视图 Get the current view
Using acView As ViewTableRecord = acDoc.Editor.GetCurrentView()
'' 获得当前视图的中心 Get the center of the current view
Dim pCenter As Point3d = New Point3d(acView.CenterPoint.X, _
acView.CenterPoint.Y, 0)
'' 设置使用的缩放比例 Set the scale factor to use
Dim dScale As Double = 0.5
'' 使用当前视图的中心缩放视图 Scale the view using the center of the current view
Zoom(New Point3d(), New Point3d(), pCenter, 1 / dScale)
End Using
End Sub
[CommandMethod("ZoomScale")]
static public void ZoomScale()
{
// 获得当前文档 Get the current document
Document acDoc = Application.DocumentManager.MdiActiveDocument;
// 获得当前视图 Get the current view
using (ViewTableRecord acView = acDoc.Editor.GetCurrentView())
{
// 获得当前视图的中心 Get the center of the current view
Point3d pCenter = new Point3d(acView.CenterPoint.X,
acView.CenterPoint.Y, 0);
// 设置使用的缩放比例 Set the scale factor to use
double dScale = 0.5;
// 使用当前视图的中心缩放视图 Scale the view using the center of the current view
Zoom(new Point3d(), new Point3d(), pCenter, 1 / dScale);
}
}