用户指定的点可用于获取封闭区域的面积。 您可以测量由用户指定的 2D 或 3D 点定义的任意闭合区域。这些点必须是共面的。 从用户处获取点指定的区域
计算由用户输入的点定义的区域本示例提示用户输入 5 个点。然后,从输入的点中创建折线。折线是闭合的,折线的面积显示在消息框中。 Sub Ch3_CalculateDefinedArea() Dim p1 As Variant Dim p2 As Variant Dim p3 As Variant Dim p4 As Variant Dim p5 As Variant ' Get the points from the user p1 = ThisDrawing.Utility.GetPoint(, vbCrLf & "First point: ") p2 = ThisDrawing.Utility.GetPoint(p1, vbCrLf & "Second point: ") p3 = ThisDrawing.Utility.GetPoint(p2, vbCrLf & "Third point: ") p4 = ThisDrawing.Utility.GetPoint(p3, vbCrLf & "Fourth point: ") p5 = ThisDrawing.Utility.GetPoint(p4, vbCrLf & "Fifth point: ") ' Create the 2D polyline from the points Dim polyObj As AcadLWPolyline Dim vertices(0 To 9) As Double vertices(0) = p1(0): vertices(1) = p1(1) vertices(2) = p2(0): vertices(3) = p2(1) vertices(4) = p3(0): vertices(5) = p3(1) vertices(6) = p4(0): vertices(7) = p4(1) vertices(8) = p5(0): vertices(9) = p5(1) Set polyObj = ThisDrawing.ModelSpace.AddLightWeightPolyline(vertices) polyObj.Closed = True ThisDrawing.Application.ZoomAll ' Display the area for the polyline MsgBox "The area defined by the points is " & _ polyObj.Area, , "Calculate Defined Area" End Sub 相关概念父主题: |
|Archiver|CAD开发者社区 ( 苏ICP备2022047690号-1 苏公网安备32011402011833)
GMT+8, 2025-1-8 19:23
Powered by Discuz! X3.4
Copyright © 2001-2021, Tencent Cloud.