ILocateCommandEvents_LocateFilter is not working for second datapoint

Hi folks,

I am missing something here. I want to prompt the user to click on a line in 2 different places and collect both datapoints.

If I click on text for the first datapoint it correctly says its not a line, however for the second datapoint I can click on anything and it accepts it... help! 

 

sub main()

CommandState.StartLocate New clsLocatePts

end sub

 

 

' ---------------------------class code ---------------------------------------

Option Explicit
Implements ILocateCommandEvents

Dim Mypoint(1) As Point3d ' holds the data point user provides
Dim numPointsPlaced As Long ' number of datapoints placed

Private Sub ILocateCommandEvents_Start()
    Application.ShowCommand ""
    Application.ShowPrompt "Select first point on line, RESET to exit"
    numPointsPlaced = 0
End Sub

Private Sub ILocateCommandEvents_Accept(ByVal Element As Element, Point As Point3d, ByVal view As view)
On Error GoTo err
    If numPointsPlaced = 0 Then
        CommandState.StartDynamics
        Mypoint(0) = Point ' capture first point
        MsgBox "Point 1 captured"
        Application.ShowPrompt "Select Second Point on line, RESET to restart"
    Else
 CommandState.SetLocateCursor
        MsgBox "Point 2 captured"
        Mypoint(1) = Point ' capture second point

        ' have 2 points time for H/W calc
       MsgBox "time to calc"

        CommandState.StartDefaultCommand
        numPointsPlaced = 0
        Exit Sub
    End If

    numPointsPlaced = numPointsPlaced + 1
    Exit Sub
err:
    MsgBox "Datapoint module error " & err.Number & vbCrLf & err.Description
End Sub

Private Sub ILocateCommandEvents_LocateFilter(ByVal Element As Element, Point As Point3d, Accepted As Boolean)

' add in line string later

    If Element.Type = msdElementTypeLine Then
        Accepted = True
    Else
        Accepted = False
    End If

End Sub

Private Sub ILocateCommandEvents_LocateFailed()
'    ShowStatus "Not a line element"
MsgBox "Not a line element"
End Sub

Private Sub ILocateCommandEvents_Dynamics(Point As Point3d, ByVal view As view, ByVal DrawMode As MsdDrawingMode)

End Sub

Private Sub ILocateCommandEvents_LocateReset()
    '????
End Sub

Private Sub ILocateCommandEvents_Cleanup()

End Sub

Parents
  • Hi,

    In your case, you can use IPrimitiveCommandEvents.

    Set cursor to Locate in the start event of IPrimitiveCommandEvents.

    Private Sub IPrimitiveCommandEvents_Start()

    CommandState.SetLocateCursor

    End Sub

    In the Data Point event, locate the element by using the data point and validate it.

    If it is a valid element, store the data point.

    Private Sub IPrimitiveCommandEvents_DataPoint(Point As Point3d, ByVal View As View)

    Dim elm As Element

    Set elm = CommandState.LocateElement(Point, View, True)

    If elm Is Nothing Then

    MsgBox "Pick on Line", vbInformation

    Exit Sub

    End If

    If elm.IsLineElement = False Then

       MsgBox "Invalid Element", vbInformation

    Else

       If ptcount = 1 Then

           dataPoint1 = Point

           ptcount = 2

       Else

           dataPoint2 = Point

           '...........

           '...........

       End If

    End If

    End Sub

    HTH,

    Siva

    Answer Verified By: rpsmith 

Reply
  • Hi,

    In your case, you can use IPrimitiveCommandEvents.

    Set cursor to Locate in the start event of IPrimitiveCommandEvents.

    Private Sub IPrimitiveCommandEvents_Start()

    CommandState.SetLocateCursor

    End Sub

    In the Data Point event, locate the element by using the data point and validate it.

    If it is a valid element, store the data point.

    Private Sub IPrimitiveCommandEvents_DataPoint(Point As Point3d, ByVal View As View)

    Dim elm As Element

    Set elm = CommandState.LocateElement(Point, View, True)

    If elm Is Nothing Then

    MsgBox "Pick on Line", vbInformation

    Exit Sub

    End If

    If elm.IsLineElement = False Then

       MsgBox "Invalid Element", vbInformation

    Else

       If ptcount = 1 Then

           dataPoint1 = Point

           ptcount = 2

       Else

           dataPoint2 = Point

           '...........

           '...........

       End If

    End If

    End Sub

    HTH,

    Siva

    Answer Verified By: rpsmith 

Children
No Data