図面ウィンドウでイメージの表示倍率を変更する必要がある場合は、現在のビューのWidth および Height プロパティを変更します。ビューのサイズを変更する場合は、同じ係数で Width と Height プロパティを変更します。現在のビューのサイズを変更する場合、一般的には、次のいずれかに基づいて尺度係数が計算されます。
このサンプル コードは、「現在のビューを操作する」で定義されているズーム操作を使用して、現在のビューを 50% 縮小する方法を示しています。
ズーム操作に合計 4 つの値が渡されますが、最初の 2 つは使用されていない新しい 3D 点です。渡される 3 番目の値はビューのサイズ変更で使用される中心点であり、渡される最後の値はビューのサイズ変更で使用される尺度係数です。
<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);
}
}
Sub ZoomScale()
Dim scalefactor As Double
Dim scaletype As Integer
scalefactor = 0.5
scaletype = acZoomScaledRelative
ThisDrawing.Application.ZoomScaled scalefactor, scaletype
End Sub