CAD开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

AutoCAD 2024 开发者帮助

GetBoundingBox 方法 (ActiveX)

2024-5-18 19:07| 发布者: admin| 查看: 102| 评论: 0|原作者: admin|来自: AutoCAD

GetBoundingBox 方法 (ActiveX)

获取包含指定对象的框的两个点。

支持的平台:仅限 Windows

签名

VBA:

object.GetBoundingBox MinPoint, MaxPoint
对象

类型:所有绘图对象AttributeReference尺寸

此方法应用到的对象。

闵点

访问:仅输出

类型:变体(双打的三元素阵列)

指定对象边界框最小点的 3D WCS 坐标。

马克斯波因特

访问:仅输出

类型:变体(双打的三元素阵列)

指定对象边界框最大点的 3D WCS 坐标。

返回值 (RetVal)

无返回值。

言论

拐角以 WCS 坐标返回,框边平行于 WCS XYZ 轴。



例子

VBA:

Sub Example_GetBoundingBox()
    ' This example creates a line in model space. It then finds the
    ' bounding box for the line and displays the corners of the box.
    
    Dim startPoint(0 To 2) As Double
    Dim endPoint(0 To 2) As Double
    Dim lineObj As AcadLine

    ' Create the Line object in model space
    startPoint(0) = 2#: startPoint(1) = 2#: startPoint(2) = 0#
    endPoint(0) = 4#: endPoint(1) = 4#: endPoint(2) = 0#
    Set lineObj = ThisDrawing.ModelSpace.AddLine(startPoint, endPoint)
    ZoomAll
    
    Dim minExt As Variant
    Dim maxExt As Variant
    
    ' Return the bounding box for the line and return the minimum
    ' and maximum extents of the box in the minExt and maxExt variables.
    lineObj.GetBoundingBox minExt, maxExt
    
    ' Print the min and max extents
    MsgBox "The extents of the bounding box for the line are:" & vbCrLf _
         & "Min Extent: " & minExt(0) & "," & minExt(1) & "," & minExt(2) _
         & vbCrLf & "Max Extent: " & maxExt(0) & "," & maxExt(1) & "," & maxExt(2), vbInformation, "GetBoundingBox Example"
         
End Sub

可视化 LISP:

(vl-load-com)
(defun c:Example_GetBoundingBox()
    ;; This example creates a line in model space. It then finds the
    ;; bounding box for the line and displays the corners of the box.
    (setq acadObj (vlax-get-acad-object))
    (setq doc (vla-get-ActiveDocument acadObj))
  
    ;; Create the Line object in model space
    (setq startPoint (vlax-3D-point 2 2 0))
    (setq endPoint (vlax-3D-point 4 4 0))
    (setq modelSpace (vla-get-ModelSpace doc))
    (setq lineObj (vla-AddLine modelSpace startPoint endPoint))
    (vla-ZoomAll acadObj)
    
    ;; Return the bounding box for the line and return the minimum
    ;; and maximum extents of the box in the minExt and maxExt variables.
    (vla-GetBoundingBox lineObj 'minExt 'maxExt)
    (setq minExt (vlax-safearray->list minExt)
	         maxExt (vlax-safearray->list maxExt))
  
    ;; Print the min and max extents
    (alert (strcat "The extents of the bounding box for the line are:"
                   "\nMin Extent: " (rtos (nth 0 minExt) 2) "," (rtos (nth 1 minExt) 2) "," (rtos (nth 2 minExt) 2)
                   "\nMax Extent: " (rtos (nth 0 maxExt) 2) "," (rtos (nth 1 maxExt) 2) "," (rtos (nth 2 maxExt) 2)))
)

路过

雷人

握手

鲜花

鸡蛋

最新评论

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

GMT+8, 2024-12-15 11:38

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

返回顶部