
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I'm trying to create a VBA routine that asks the user to select a closed 2D polyline and adds all objects (inside or crossing the polyline) to a selection set. The second part of my routine runs through all the items in the selection set, searches for specific blocks and exports them to excel for further processing. The first part is where I'm having a lot of difficulties. From what I read on other sites, using selectbypolygon should work if I convert the 2D coordinates to 3D coordinates which my routine does. The problem is that my selection set is allways empty and the last line never runs because ssetObj appears as empty. Can you help me understand what is wrong with my code bellow?
Sub test_pl()
Dim oEnt As AcadEntity
Dim Pt(0 To 2) As Double
Dim oLWP As AcadLWPolyline
Dim oP As AcadPolyline
Dim dblNewCords As Variant
Dim ssetObj As AcadSelectionSet
On Error Resume Next
ThisDrawing.SelectionSets.Delete ("TEST_SSET2")
ThisDrawing.Utility.GetEntity oEnt, Pt, "Select a polyline"
Set oLWP = oEnt
dblCurCords = oLWP.Coordinates
iMaxCurArr = UBound(dblCurCords)
iMaxNewArr = ((iMaxCurArr + 1) * 1.5) - 1
ReDim dblNewCords(iMaxNewArr) As Double
iCurArrIdx = 0: iCnt = 1
For iNewArrIdx = 0 To iMaxNewArr
If iCnt = 3 Then
dblNewCords(iNewArrIdx) = 0
iCnt = 1
Else
dblNewCords(iNewArrIdx) = dblCurCords(iCurArrIdx)
iCurArrIdx = iCurArrIdx + 1
iCnt = iCnt + 1
End If
Next
Set ssetObj = ThisDrawing.SelectionSets.Add("TEST_SSET2")
ssetObj.SelectByPolygon acSelectionSetWindowPolygon, dblNewCords
MsgBox ssetObj.Count
End Sub
Solved! Go to Solution.