Jump to content

Add selected point into a selection set


Recommended Posts

Posted

Dear,

I get point by ThisDrawing.Utility.GetPoint method and add it into a selectionset but this selectionset is still null !

Is there anything wrong ? Please show me.

Thank you !

 

 
Sub ClickPoint()
Dim returnPnt As Variant
Dim ssetPoint As AcadSelectionSet
Dim Point As AcadPoint

returnPnt = ThisDrawing.Utility.GetPoint
Set Point = ThisDrawing.ModelSpace.AddPoint(returnPnt)
   Dim check As Boolean
   Dim Count As Integer
   Count = ThisDrawing.SelectionSets.Count
   check = False
   If Count > 0 Then
       For i = 0 To Count - 1
           If ThisDrawing.SelectionSets.Item(i).Name <> "ssetPoint" Then
               check = False
           Else
               check = True
               Exit For
           End If
       Next i
   End If

   If check = False Then
       Set ssetPoint = ThisDrawing.SelectionSets.Add("ssetPoint")
   Else
       Set ssetPoint = ThisDrawing.SelectionSets.Item(i)
       ssetPoint.Clear
   End If

   ssetPoint.SelectAtPoint returnPnt

   MsgBox ssetPoint.Count
End Sub


Posted

That seems like it should work. Perhaps the graphics display, an integral part of the “Select” methods, is not updated in time to present the proper cues to the SelectAtPoint call.

 

Even if it were, though, it may be better to add the Point entity to the SelSet explicitly, in case other entities were at that location.

 

Sub ClickPoint()
Dim returnPnt As Variant
Dim ssetPoint As AcadSelectionSet
Dim Point(0) As AcadPoint

returnPnt = ThisDrawing.Utility.GetPoint
Set Point(0) = ThisDrawing.ModelSpace.AddPoint(returnPnt)
   Dim check As Boolean
   Dim Count As Integer
   Count = ThisDrawing.SelectionSets.Count
   check = False
   If Count > 0 Then
       For i = 0 To Count - 1
           If ThisDrawing.SelectionSets.Item(i).Name <> "ssetPoint" Then
               check = False
           Else
               check = True
               Exit For
           End If
       Next i
   End If

   If check = False Then
       Set ssetPoint = ThisDrawing.SelectionSets.Add("ssetPoint")
   Else
       Set ssetPoint = ThisDrawing.SelectionSets.Item(i)
       ssetPoint.Clear
   End If

   ssetPoint.AddItems Point

   MsgBox ssetPoint.Count
End Sub

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...