Public Sub Export_with_query(ByVal ep_layer, ByVal ep_name, ByVal ep_query)
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 IExportOperation
Dim pExportOp As ESRI.ArcGIS.GeoDatabaseUI.IExportOperation
Try
pDoc = My.ArcMap.Document
pMap = pDoc.FocusMap
pFLayer = pMap.Layer(ep_layer)
pFc = pFLayer.FeatureClass
'Get the FcName from the featureclass
pDataset = pFc
pINFeatureClassName = pDataset.FullName
pInDsName = pINFeatureClassName
'Get the selection set
pFSel = pFLayer
pSelSet = pFSel.SelectionSet
Dim pQFilter As IQueryFilter
pQFilter = New QueryFilter
pQFilter.WhereClause = "TYPE = '" & ep_query & "'"
If pFc.FeatureCount(pQFilter) = 0 Then
Exit Sub
Else
'Define the output feature class name
pFeatureClassName = New FeatureClassName
pOutDatasetName = pFeatureClassName
pOutDatasetName.Name = ep_name
pWorkspaceName = New WorkspaceName
If Chk_default_path.Checked = True Then
pWorkspaceName.PathName = "c:\map"
Else
pWorkspaceName.PathName = Txt_path.Text
End If
pWorkspaceName.WorkspaceFactoryProgID = _
"esriCore.shapefileworkspacefactory.1"
pOutDatasetName.WorkspaceName = pWorkspaceName
'pFeatureClassName.FeatureType = esriFTSimple
pFeatureClassName.FeatureType = ESRI.ArcGIS.Geodatabase.esriFeatureType.esriFTSimple
' pFeatureClassName.ShapeType = esriGeometryAny
pFeatureClassName.ShapeType = ESRI.ArcGIS.Geometry.esriGeometryType.esriGeometryAny
pFeatureClassName.ShapeFieldName = "Shape"
'Export
' pExportOp = New ExportOperation
pExportOp = New ESRI.ArcGIS.GeoDatabaseUI.ExportOperation
' pExportOp.ExportFeatureClass(pInDsName, Nothing, pSelSet, Nothing, pOutDatasetName, 0)
pExportOp.ExportFeatureClass(pInDsName, pQFilter, pSelSet, Nothing, pOutDatasetName, 0)
'pExportOp.ExportFeatureClass(pInFClassName, pQFilter, pSelSet, pGeomDef, pOutDatasetName, 0)
' End If
Catch ex As Exception
MessageBox.Show("Error exporting map: " & vbCrLf & ex.ToString)
Finally
End Try
End Sub
#End Region
Public Sub Export_with_query(ByVal ep_layer, ByVal ep_name, ByVal ep_query)
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 IExportOperation
Dim pExportOp As ESRI.ArcGIS.GeoDatabaseUI.IExportOperation
Try
pDoc = My.ArcMap.Document
pMap = pDoc.FocusMap
pFLayer = pMap.Layer(ep_layer)
pFc = pFLayer.FeatureClass
'Get the FcName from the featureclass
pDataset = pFc
pINFeatureClassName = pDataset.FullName
pInDsName = pINFeatureClassName
'Get the selection set
pFSel = pFLayer
pSelSet = pFSel.SelectionSet
Dim pQFilter As IQueryFilter
pQFilter = New QueryFilter
pQFilter.WhereClause = "TYPE = '" & ep_query & "'"
If pFc.FeatureCount(pQFilter) = 0 Then
Exit Sub
Else
'Define the output feature class name
pFeatureClassName = New FeatureClassName
pOutDatasetName = pFeatureClassName
pOutDatasetName.Name = ep_name
pWorkspaceName = New WorkspaceName
If Chk_default_path.Checked = True Then
pWorkspaceName.PathName = "c:\map"
Else
pWorkspaceName.PathName = Txt_path.Text
End If
pWorkspaceName.WorkspaceFactoryProgID = _
"esriCore.shapefileworkspacefactory.1"
pOutDatasetName.WorkspaceName = pWorkspaceName
'pFeatureClassName.FeatureType = esriFTSimple
pFeatureClassName.FeatureType = ESRI.ArcGIS.Geodatabase.esriFeatureType.esriFTSimple
' pFeatureClassName.ShapeType = esriGeometryAny
pFeatureClassName.ShapeType = ESRI.ArcGIS.Geometry.esriGeometryType.esriGeometryAny
pFeatureClassName.ShapeFieldName = "Shape"
'Export
' pExportOp = New ExportOperation
pExportOp = New ESRI.ArcGIS.GeoDatabaseUI.ExportOperation
' pExportOp.ExportFeatureClass(pInDsName, Nothing, pSelSet, Nothing, pOutDatasetName, 0)
pExportOp.ExportFeatureClass(pInDsName, pQFilter, pSelSet, Nothing, pOutDatasetName, 0)
'pExportOp.ExportFeatureClass(pInFClassName, pQFilter, pSelSet, pGeomDef, pOutDatasetName, 0)
' End If
Catch ex As Exception
MessageBox.Show("Error exporting map: " & vbCrLf & ex.ToString)
Finally
End Try
End Sub