rwelikal

Select Features Tool - VB.NET

Discussion created by rwelikal on Jun 15, 2010
Latest reply on Jun 17, 2010 by rwelikal
Hi All,
The code belows is the OnClick procedure for one of the custom tools I'm making.  The problem is, when the initial tool is activated, I want it to check if the appropriate features are selected.  If it isn't selected, I want the Select Features tool in ArcMap to activate so the user can select the specific feature. 
I get an error "m_application.CurrentTool = pCommand".
If anyone has an advice for me, that'd be greatly appreciated.

Thanks

    Public Overrides Sub OnClick()
        Try
           
            'TODO: Add ClipTool.OnClick implementation
            Dim pMap As IMxDocument = GetMxDocumentFromArcMap(m_application)
            Dim pFeatLayer As IFeatureLayer = pMap.SelectedLayer
            Dim pFeatSelection As IFeatureSelection = pFeatLayer
            Dim pSelSet As ISelectionSet
            pSelSet = pFeatSelection.SelectionSet

            If pSelSet.Count = 0 Then
                MsgBox("Please make a selection")

                Dim pCommand As ICommand
                pCommand = New ControlsSelectFeaturesToolClass ' The selectfeatures tool
                pCommand.OnCreate(m_application)
                If pCommand.Enabled = True Then
                    m_application.CurrentTool = pCommand
                End If
                Exit Sub
            End If
            Call CreateWindow(GetMxDocumentFromArcMap(m_application))

        Catch ex As Exception
            MsgBox(ex.Message)
        End Try
    End Sub

Outcomes