AnsweredAssumed Answered

Export to SHP with WhereClause

Question asked by siggisal on Oct 17, 2015
Latest reply on Oct 24, 2015 by siggisal

Hi

 

I use this code to export to SHP but if the WhereClause  is null it still make empty SHP file

How can I stop the export if pQFilter.WhereClause is notthing

 

 

 

       Dim pDoc As IMxDocument

        Dim pMap As IMap

        Dim pFLayer As IFeatureLayer

        Dim pFc As IFeatureClass

        Dim pINFeatureClassName As IFeatureClassName

        Dim pDataset As IDataset

        Dim pInDsName As IDatasetName

        Dim pFSel As IFeatureSelection

        Dim pSelSet As ISelectionSet

        Dim pFeatureClassName As IFeatureClassName

        Dim pOutDatasetName As IDatasetName

        Dim pWorkspaceName As IWorkspaceName

        Dim pExportOp As ESRI.ArcGIS.GeoDatabaseUI.IExportOperation

 

 

        pDoc = My.ArcMap.Document

        pMap = pDoc.FocusMap

        pFLayer = pMap.Layer(ep_layer)

        pFc = pFLayer.FeatureClass

 

 

        pDataset = pFc

        pINFeatureClassName = pDataset.FullName

        pInDsName = pINFeatureClassName

 

 

        Dim pQFilter As IQueryFilter

        pQFilter = New QueryFilter

 

 

        pQFilter.WhereClause = "TYPE '" & ep_query & "'"

 

 

        pFSel = pFLayer

        pSelSet = pFSel.SelectionSet

        If pSelSet.Count = 0 Then

 

            Exit Sub

        End If

 

 

        If pFc.FeatureCount(pQFilter) <= 1 Then

          

            Exit Sub

 

 

        ElseIf pFc.FeatureCount(pQFilter) >= 1 Then

 

 

            pFeatureClassName = New FeatureClassName

            pOutDatasetName = pFeatureClassName

            pOutDatasetName.Name = ep_name

            pWorkspaceName = New WorkspaceName

            pWorkspaceName.PathName = path.txt

            pWorkspaceName.WorkspaceFactoryProgID = esriCore.shapefileworkspacefactory.1"

            pOutDatasetName.WorkspaceName = pWorkspaceName

            pFeatureClassName.FeatureType = ESRI.ArcGIS.Geodatabase.esriFeatureType.esriFTSimple

            pFeatureClassName.ShapeType = ESRI.ArcGIS.Geometry.esriGeometryType.esriGeometryAny

            pFeatureClassName.ShapeFieldName = "Shape"

            pExportOp = New ESRI.ArcGIS.GeoDatabaseUI.ExportOperation

            pExportOp.ExportFeatureClass(pInDsName, pQFilter, pSelSet, Nothing, pOutDatasetName, 0)

 

 

        Else

          

            Exit Sub

        End If

Outcomes