Select at point not working as expected... plz help

Select at point not working as expected... plz help

Anonymous
Not applicable
652 Views
3 Replies
Message 1 of 4

Select at point not working as expected... plz help

Anonymous
Not applicable

I'm trying to select all objects at a particular point, but using .SelectAtPoint appears to only return one entity, even though multiple lines are connected to the point. Could someone tell me what I'm doing wrong?

 

Sub getSelection()

    Dim selection As AcadEntity
    Dim selPt As Variant   
    ThisDrawing.Utility.GetEntity selection, selPt, "Select a segment..."

    Dim selStart As Variant
    selStart = selection.StartPoint

    Dim connSetStart As AcadSelectionSet
    Set connSetStart = ThisDrawing.SelectionSets.Add("ConnToStart")
    
    connSetStart.SelectAtPoint selStart
    
    Dim thing1 As Variant
    For Each thing1 In connSetStart
        Debug.Print "connSetStart: " & thing1.ObjectName
        Debug.Print "ID: " & thing1.ObjectID
    Next thing1

    Debug.Print "#objs in startset: " & connSetStart.Count

End Sub 

 

0 Likes
Accepted solutions (1)
653 Views
3 Replies
Replies (3)
Message 2 of 4

Hallex
Advisor
Advisor
Accepted solution

Try to change Selection mode argument:

 

Option Explicit

Sub test()

     Dim oEnt As AcadEntity
     Dim oPoly As AcadLWPolyline
     Dim setObj As AcadSelectionSet
     Dim setColl As AcadSelectionSets
     Dim pickPnt As Variant
     Dim setName As String
     Dim selMod As Long
     Dim gpCode(1) As Integer
     Dim dataValue(1) As Variant
     Dim dxfcode, dxfdata
     Dim selPts As Variant
     Dim p1(2) As Double
     Dim p2(2) As Double
     Dim pickPt As Variant
     Dim wcsPt As Variant

     On Error GoTo SayMeAbout
     gpCode(0) = 0: gpCode(1) = 8
     dataValue(0) = "lwpolyline": dataValue(1) = "0"
     dxfcode = gpCode: dxfdata = dataValue
     setName = "$PolygonSelect$"
     ThisDrawing.SetVariable "osmode", 32
     pickPnt = ThisDrawing.Utility.GetPoint(, vbCr & "Enter a point: ")
   
     With ThisDrawing
          Set setColl = .SelectionSets
          For Each setObj In setColl
               If setObj.Name = setName Then
                    .SelectionSets.Item(setName).Delete
                    Exit For
               End If
          Next
          Set setObj = .SelectionSets.Add(setName)
     End With
     
     p1(0) = pickPnt(0) + 0.01: p1(1) = pickPnt(1) + 0.01
     p2(0) = pickPnt(0) - 0.01: p2(1) = pickPnt(1) - 0.01
     selMod = AcSelect.acSelectionSetCrossing
     
     setObj.Select selMod, p1, p2, dxfcode, dxfdata
     setObj.Highlight True
     MsgBox "Selected: " & CStr(setObj.Count)
     ' >> do your stuffs here :
     For Each oEnt In setObj
          Set oPoly = oEnt
          oPoly.Lineweight = acLnWt040
          oPoly.Update
     Next

SayMeAbout:
If Err.Number <> 0 Then
     MsgBox Err.Description
     End If

End Sub

 

~'J'~

_____________________________________
C6309D9E0751D165D0934D0621DFF27919
0 Likes
Message 3 of 4

Anonymous
Not applicable

Thank you, Hallex. This is a great workaround, as it lets me easily build in a 'fuzz factor' by altering the size of the selection window.

0 Likes
Message 4 of 4

Hallex
Advisor
Advisor

Glad I could help

Cheers 🙂

 

~'J'~

_____________________________________
C6309D9E0751D165D0934D0621DFF27919
0 Likes