[VBA]关于选择集
我想用一闭合多段线为边界选择其内部的图形,采用selectbypolygen方法,但发现与边界相连的多边形或线段都选不上,如下图,有其它方法吗?d:\未命名.bmp
object.SelectByPolygon Mode, PointsList, FilterType, FilterData
Mode用acSelectionSetCrossingPolygon
莫名你好,如果Mode采用acSelectionSetCrossingPolygon 的话与边界相连的外面的多边形也会被选中。我主要是用来计算图斑面积时扣除内部图斑的面积,不知有没有好一点的办法。
d:\未命名.bmp
沉到底了,自己顶一下,大家给个答案啊 自己顶
程序如下:
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
还是自己顶,有人回答一下是如果根本没办法解决有话就不顶了
页:
[1]