明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
12
返回列表 发新帖
楼主: lxxl

求助,VBA编程,计算CAD任意图形的面积的程序。紧急

[复制链接]
发表于 2018-8-25 00:22 | 显示全部楼层
抄书
  1. Public Sub GetArea()
  2. Dim n&
  3. n = ThisDrawing.ModelSpace.Count
  4. Dim pt
  5. pt = ThisDrawing.Utility.GetPoint(, "选择内部点:")
  6. ThisDrawing.SendCommand "-Boundary" & vbCr & pt(0) & "," & pt(1) & vbCr & vbCr

  7. Dim objPoly As AcadLWPolyline
  8. If ThisDrawing.ModelSpace.Count > n Then
  9.   Set objPoly = ThisDrawing.ModelSpace.Item(n)
  10.   MsgBox objPoly.Area
  11.   objPoly.Delete
  12. Else
  13.   MsgBox "未发现有效边界!"
  14. End If
  15. End Sub
您需要登录后才可以回帖 登录 | 注册

本版积分规则

小黑屋|手机版|CAD论坛|CAD教程|CAD下载|联系我们|关于明经|明经通道 ( 粤ICP备05003914号 )  
©2000-2023 明经通道 版权所有 本站代码,在未取得本站及作者授权的情况下,不得用于商业用途

GMT+8, 2024-3-28 21:58 , Processed in 0.427949 second(s), 16 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表