CAD开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

ObjectARX 开发指南

显示绘图范围和限制 (.NET)

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

图形的范围或限制用于定义最外层对象出现的边界或由当前空间限制定义的区域。

计算当前空间的范围

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

  • Extmin 和 Extmax- 返回模型空间的范围。
  • Pextmin 和 Pextmax - 返回当前图纸空间布局的范围。

获得当前空间的范围后,可以计算当前视图的 and 属性的新值。视图的新宽度使用以下公式计算:WidthHeight

dWidth = MaxPoint.X - MinPoint.X

视图的新高度使用以下公式计算:

dHeight = MaxPoint.Y - MinPoint.Y

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

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

计算当前空间的限制

要根据当前空间的限制更改图形的显示,请使用对象的 and 和属性。返回定义当前空间限制的点后,可以使用前面提到的公式来计算新视图的宽度、高度和中心点。LimminLimmaxPlimminPlimmaxDatabase

放大到当前空间的范围和限制

此示例代码演示如何使用“操作当前视图”主题中定义的 Zoom 过程显示当前空间的限制范围。

虽然 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 代码参考

Sub ZoomExtents()
    ThisDrawing.Application.ZoomExtents
End Sub
 
Sub ZoomLimits()
    Dim point1(0 To 2) As Double
    Dim point2(0 To 2) As Double
 
    point1(0) = ThisDrawing.GetVariable("LIMMIN")(0)
    point1(1) = ThisDrawing.GetVariable("LIMMIN")(1)
    point1(2) = 0#
 
    point2(0) = ThisDrawing.GetVariable("LIMMAX")(0)
    point2(1) = ThisDrawing.GetVariable("LIMMAX")(1)
    point2(2) = 0#
 
    ThisDrawing.Application.ZoomWindow point1, point2
End Sub

路过

雷人

握手

鲜花

鸡蛋

最新评论

python对CAD二次开发

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

GMT+8, 2024-5-7 07:55

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

返回顶部