CAD开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

ObjectARX 开发指南

缩放视图 (.NET)

2023-1-1 16:15| 发布者: admin| 查看: 695| 评论: 0|来自: AutoCAD

如果需要在绘图窗口中增大或减小图像的放大倍数,请更改当前视图的 and 属性。调整视图大小时,请确保按相同的因子更改属性。调整当前视图大小时计算的比例因子通常基于以下情况之一:WidthHeightWidthHeight

  • 相对于绘图限制
  • 相对于当前视图
  • 相对于图纸空间单位

使用指定比例放大活动图形

此示例代码演示如何使用“操作当前视图”主题中定义的 Zoom 过程将当前视图减少 50%。

虽然 Zoom 过程总共传递了四个值,但前两个是未使用的新 3D 点。传递的第三个值是用于调整视图大小的中心点,传递的最后一个值是用于调整视图大小的比例因子。

VB.NET

<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

C#

[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);
    }
}

VBA/ActiveX 代码参考

Sub ZoomScale()
    Dim scalefactor As Double
    Dim scaletype As Integer
 
    scalefactor = 0.5
    scaletype = acZoomScaledRelative
 
    ThisDrawing.Application.ZoomScaled scalefactor, scaletype
End Sub

路过

雷人

握手

鲜花

鸡蛋

最新评论

AutoCAD ObjectARX(VC)

QQ|Archiver|CAD开发者社区 ( 苏ICP备2022047690号-1 )

GMT+8, 2024-5-6 19:46

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

返回顶部