<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: arcpy.conversion.ExportFeatures to vb.net in ArcGIS Pro SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/arcpy-conversion-exportfeatures-to-vb-net/m-p/1403992#M11314</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;Your shared code is not so accurate. Code below works:&lt;/P&gt;&lt;LI-CODE lang="c"&gt;    Protected async Overrides Sub OnClick()
        Try


            Dim currentLayer = MapView.Active.Map.GetLayersAsFlattenedList().OfType(Of FeatureLayer).FirstOrDefault

            If currentLayer.ConnectionStatus = ConnectionStatus.Broken Then

            End If
            If currentLayer.SelectionCount = 0 Then

            Else

                Dim out_features = "C:\PATH\file.shp"
                Dim where_clause = "TYPE = 80"
                Dim use_field_alias_as_name = "NOT_USE_ALIAS"
                Dim sort_field = "None"

                Dim progDlg = New ProgressDialog("Export map" &amp;amp; vbCrLf &amp;amp; "Go get a coffee", "Cancel")
                progDlg.Show()
                Dim progsrc=New CancelableProgressorSource(progDlg)

                Dim outpath = System.IO.Path.GetDirectoryName(out_features)


                If Not System.IO.Directory.Exists(outpath) Then System.IO.Directory.CreateDirectory(outpath)
                Dim valueArray = Await QueuedTask.Run(Function()
                                                          Return Geoprocessing.MakeValueArray(currentLayer, out_features, where_clause, use_field_alias_as_name, sort_field)
                                                      End Function)
                Dim flags As GPExecuteToolFlags = GPExecuteToolFlags.GPThread
                Dim gpResult As IGPResult = Await Geoprocessing.ExecuteToolAsync("conversion.ExportFeatures", valueArray, Nothing, progsrc.CancellationTokenSource.Token, Nothing, flags)

                progDlg.Hide()
                Dim val = If(String.IsNullOrEmpty(gpResult.ReturnValue), $"Error in gp tool: {gpResult.ErrorMessages}", $"Ok: {gpResult.ReturnValue}")
            End If

        Catch ex As Exception
            MessageBox.Show(ex.Message)
        End Try
    End Sub&lt;/LI-CODE&gt;</description>
    <pubDate>Mon, 01 Apr 2024 18:49:03 GMT</pubDate>
    <dc:creator>GKmieliauskas</dc:creator>
    <dc:date>2024-04-01T18:49:03Z</dc:date>
    <item>
      <title>arcpy.conversion.ExportFeatures to vb.net</title>
      <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/arcpy-conversion-exportfeatures-to-vb-net/m-p/1403921#M11313</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Hi&amp;nbsp;&lt;/P&gt;&lt;P&gt;I was try to use convert arcpy.conversion.ExportFeatures to VB:NET&lt;BR /&gt;when I run the code nothing happened I see the Progress dialog then I don't get the shapefile&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;  count1 = int(arcpy.GetCount_management("LAYERNAME").getOutput(0)) 
if count1 &amp;gt; 0:
     #print('Layer has a selection')
        arcpy.conversion.ExportFeatures(
    in_features="LAYERNAME",
    out_features=r"C:\PATH\file.shp",
    where_clause="TYPE = 80",
    use_field_alias_as_name="NOT_USE_ALIAS",    
    sort_field=None
)
else:
    print('Layer has no selection')  &lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="c"&gt; 
  Try


       Dim currentLayer = GetBasicFeaturLayer(layerpath)
       If currentLayer.ConnectionStatus = ConnectionStatus.Broken Then

       End If
       If currentLayer.SelectionCount = 0 Then

       Else

           Dim in_features = "LAYERNAME"
           Dim out_features = "C:\PATH\file.shp"
           Dim where_clause = "TYPE = 80"
           Dim use_field_alias_as_name = "NOT_USE_ALIAS"
           Dim sort_field = "None"

           Dim progDlg = New ProgressDialog("Export map" &amp;amp; vbCrLf &amp;amp; "Go get a coffee", "Cancel")
           progDlg.Show()
           Dim progsrc=New CancelableProgressorSource(progDlg)
           If Not System.IO.Directory.Exists(outpath) Then System.IO.Directory.CreateDirectory(outpath)
           Dim valueArray = Await QueuedTask.Run(Function()
                                                     Dim inlayers As List(Of String) = New List(Of String)()
                                                     inlayers.Add(layerpath)
                                                     Return Geoprocessing.MakeValueArray(inlayers, outpath, where_clause, use_field_alias_as_name, sort_field)
                                                 End Function)
           Dim flags As GPExecuteToolFlags = GPExecuteToolFlags.GPThread
           Dim gpResult As IGPResult = Await Geoprocessing.ExecuteToolAsync("conversion.ExportFeatures", valueArray, Nothing, progsrc.CancellationTokenSource.Token, Nothing, flags)

           progDlg.Hide()
           Return If(String.IsNullOrEmpty(gpResult.ReturnValue), $"Error in gp tool: {gpResult.ErrorMessages}", $"Ok: {gpResult.ReturnValue}")
       End If

   Catch ex As Exception
       MessageBox.Show(ex.Message)
   End Try
   &lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 01 Apr 2024 16:39:54 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-sdk-questions/arcpy-conversion-exportfeatures-to-vb-net/m-p/1403921#M11313</guid>
      <dc:creator>SigurdurGesr</dc:creator>
      <dc:date>2024-04-01T16:39:54Z</dc:date>
    </item>
    <item>
      <title>Re: arcpy.conversion.ExportFeatures to vb.net</title>
      <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/arcpy-conversion-exportfeatures-to-vb-net/m-p/1403992#M11314</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;Your shared code is not so accurate. Code below works:&lt;/P&gt;&lt;LI-CODE lang="c"&gt;    Protected async Overrides Sub OnClick()
        Try


            Dim currentLayer = MapView.Active.Map.GetLayersAsFlattenedList().OfType(Of FeatureLayer).FirstOrDefault

            If currentLayer.ConnectionStatus = ConnectionStatus.Broken Then

            End If
            If currentLayer.SelectionCount = 0 Then

            Else

                Dim out_features = "C:\PATH\file.shp"
                Dim where_clause = "TYPE = 80"
                Dim use_field_alias_as_name = "NOT_USE_ALIAS"
                Dim sort_field = "None"

                Dim progDlg = New ProgressDialog("Export map" &amp;amp; vbCrLf &amp;amp; "Go get a coffee", "Cancel")
                progDlg.Show()
                Dim progsrc=New CancelableProgressorSource(progDlg)

                Dim outpath = System.IO.Path.GetDirectoryName(out_features)


                If Not System.IO.Directory.Exists(outpath) Then System.IO.Directory.CreateDirectory(outpath)
                Dim valueArray = Await QueuedTask.Run(Function()
                                                          Return Geoprocessing.MakeValueArray(currentLayer, out_features, where_clause, use_field_alias_as_name, sort_field)
                                                      End Function)
                Dim flags As GPExecuteToolFlags = GPExecuteToolFlags.GPThread
                Dim gpResult As IGPResult = Await Geoprocessing.ExecuteToolAsync("conversion.ExportFeatures", valueArray, Nothing, progsrc.CancellationTokenSource.Token, Nothing, flags)

                progDlg.Hide()
                Dim val = If(String.IsNullOrEmpty(gpResult.ReturnValue), $"Error in gp tool: {gpResult.ErrorMessages}", $"Ok: {gpResult.ReturnValue}")
            End If

        Catch ex As Exception
            MessageBox.Show(ex.Message)
        End Try
    End Sub&lt;/LI-CODE&gt;</description>
      <pubDate>Mon, 01 Apr 2024 18:49:03 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-sdk-questions/arcpy-conversion-exportfeatures-to-vb-net/m-p/1403992#M11314</guid>
      <dc:creator>GKmieliauskas</dc:creator>
      <dc:date>2024-04-01T18:49:03Z</dc:date>
    </item>
  </channel>
</rss>

