Message 1 of 1
How to Iterate through every line of a selectionSet?

Not applicable
03-01-2018
06:27 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I want to create a selection set for lines if their startPoint or EndPoint is at some Location,
The Code from Below only returns the value that I want from 1 line Only, it omits the others.
I want to output the endpoint and startpoint of every line (4 lines in this case)
I am new to VBA and AutoCAD it looks like I have to create an Array containing all the things selected by the selectionset
These are the Lines that I need to iterate trough:
I looks like it only selects one:
Sub test() Dim j As Integer Dim x As Object Dim startPoint As Variant Dim endPoint As Variant Dim a As AcadSelectionSet Set a = ThisDrawing.SelectionSets.Add("MySelectionSet") Dim point(0 To 2) As Double point(0) = 0: point(1) = 0: point(2) = 0 a.SelectAtPoint point MsgBox ("Selection set " & a.Name & " contains " & _ a.Count & " items") j = 0 For Each x In a MsgBox "Item " & CStr(j + 1) & " in " & a.Name _ & "is: " & x.EntityName startPoint = x.startPoint endPoint = x.endPoint MsgBox "this is " & startPoint(0) & " " & startPoint(1) & " " & startPoint(1) & " " & endPoint(0) & " " & endPoint(1) & " " & endPoint(2) j = j + 1 Next ' Delete selectionset ThisDrawing.SelectionSets.Item("MySelectionSet").Delete End Sub
I am confused with entities, Can we say that there are 4 entities in this selection set of type line?
Why is not selecting all and if it is why is the iteration only returning the value of one?
Thank You,