CAD开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

ActiveX 开发指南

相关分类

外围属性 (ActiveX)

2023-1-3 09:02| 发布者: admin| 查看: 461| 评论: 0|来自: AutoCAD

摘要: 获取内部和外部区域循环的总长度。

获取内部和外部区域循环的总长度。

支持的平台:仅窗口

签名

工 务 局:

object.Perimeter
对象

类型:区域

此属性适用的对象。

属性值

只读:是的

类型:

周长以图形单位返回。

言论

没有额外的评论。

例子

工 务 局:

Sub Example_Perimeter()
    ' This example creates a region from an arc and a line.
    ' It then returns the length of the perimeter of the region.
    Dim curves(0 To 1) As AcadEntity
    Dim arcObj As AcadArc
    Dim lineObj As AcadLine
    
    ' Create the arc and line
    Dim centerPoint(0 To 2) As Double
    Dim radius As Double
    Dim startAngle As Double
    Dim endAngle As Double
    centerPoint(0) = 5#: centerPoint(1) = 3#: centerPoint(2) = 0#
    radius = 2#
    startAngle = 0
    endAngle = 3.141592
    Set arcObj = ThisDrawing.ModelSpace.AddArc(centerPoint, radius, startAngle, endAngle)
    Set lineObj = ThisDrawing.ModelSpace.AddLine(arcObj.startPoint, arcObj.endPoint)
    Set curves(0) = arcObj
    Set curves(1) = lineObj
    
    ' Create the region
    Dim regionObj As Variant
    regionObj = ThisDrawing.ModelSpace.AddRegion(curves)
    ZoomAll
    
    ' Find the perimeter of the region.
    Dim perimeter As Double
    perimeter = regionObj(0).perimeter
    MsgBox "The perimeter of the region is " & regionObj(0).perimeter, , "Perimeter Example"
    
End Sub

Visual LISP:

(vl-load-com)
(defun c:Example_Perimeter()
    ;; This example creates a region from an arc and a line.
    ;; It then returns the length of the perimeter of the region.
    (setq acadObj (vlax-get-acad-object))
    (setq doc (vla-get-ActiveDocument acadObj))
    (setq modelSpace (vla-get-ModelSpace doc))
    
    ;; Create the arc and line
    (setq centerPoint (vlax-3d-point 5 3 0)
          radius 2
          startAngle 0
          endAngle 3.141592)
    (setq arcObj (vla-AddArc modelSpace centerPoint radius startAngle endAngle))
    (setq lineObj (vla-AddLine modelSpace (vla-get-StartPoint arcObj) (vla-get-EndPoint arcObj)))

    (setq curves (vlax-make-safearray vlax-vbObject '(0 . 1)))
    (vlax-safearray-put-element curves 0 arcObj)
    (vlax-safearray-put-element curves 1 lineObj)
    
    ;; Create the region
    (setq regionObj (vla-AddRegion modelSpace curves))
    (vla-ZoomAll acadObj)
    
    ;; Find the perimeter of the region.
    (setq perimeter (vla-get-Perimeter (vlax-safearray-get-element (vlax-variant-value regionObj) 0)))
    (alert (strcat "The perimeter of the region is " (rtos perimeter 2)))
)

路过

雷人

握手

鲜花

鸡蛋

最新评论

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

GMT+8, 2024-5-11 20:02

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

返回顶部