明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 2857|回复: 2

计算图斑面积时的岛

[复制链接]
发表于 2006-1-5 14:50:00 | 显示全部楼层 |阅读模式

我用SelectByPolygon方法进行选择时总是不能选到与边界相连的内部多边形(图形见付件),我在开发论坛问了一个月了也没人回答,希望这里能得到帮助,先谢谢

Sub selectPl()
    Dim ent As AcadEntity
    Dim SelObj As AcadEntity
    Dim NumSel As Integer
    Dim Coord As Variant
    Dim CoordCount As Integer
    Dim NewCoord() As Double
    Dim i As Integer
   
    Dim ssetObj As AcadSelectionSet
    On Error GoTo Err1:
    Set ssetObj = ThisDrawing.SelectionSets.Add("TEST_SSET2")
   
    On Error Resume Next
    Do
        ThisDrawing.Utility.GetEntity ent, pnt, "选择多段线:"
        If Err Then Exit Sub
        If TypeName(ent) Like "IAcad*Polyline" Then Exit Do
    Loop
   
If TypeName(ent) = "IAcadLWPolyline" Then
        Coord = ent.Coordinates 

        CoordCount = (UBound(Coord) + 1) / 2 '顶点数
        '定义新的顶点坐标数组
        ReDim NewCoord(0 To (3 * CoordCount - 1)) As Double
        For i = 0 To UBound(Coord) - 1 Step 2
            NewCoord((3 * i) / 2) = Coord(i)
            NewCoord((3 * i) / 2 + 1) = Coord(i + 1)
            NewCoord((3 * i) / 2 + 2) = 0
        Next i
ElseIf TypeName(ent) = "IAcadPolyline" Then
        Coord = ent.Coordinates
        CoordCount = (UBound(Coord) + 1) / 3
        ReDim NewCoord(0 To UBound(Coord)) As Double
        For i = 0 To UBound(Coord) - 1
            NewCoord(i) = Coord(i)
            NewCoord(i) = Coord(i)
            NewCoord(i) = Coord(i)
        Next

End If
ssetObj.SelectByPolygon acSelectionSetWindowPolygon, NewCoord
ssetObj.Highlight True
ssetObj.Update
NumSel = ssetObj.Count
Exit Sub
Err1:
    ThisDrawing.SelectionSets.Item("TEST_SSET2").Delete
    Resume
End Sub

 楼主| 发表于 2006-1-5 14:53:00 | 显示全部楼层
刚才没把付件搞上

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?注册

x
发表于 2019-10-15 08:17:31 来自手机 | 显示全部楼层
谢谢分享,不错
您需要登录后才可以回帖 登录 | 注册

本版积分规则

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

GMT+8, 2024-12-23 03:12 , Processed in 0.285845 second(s), 28 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

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