<?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: Problem Converting VBA Script to Python in Geoprocessing Questions</title>
    <link>https://community.esri.com/t5/geoprocessing-questions/problem-converting-vba-script-to-python/m-p/583795#M19305</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I don't know VBA but it appears your script will find the layer with the selected line records in an open MXD and copy them.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Unless you can do advance python scripting using com components to work with ArcObjects there is not a way to replicate the same functionality you are wanting.&amp;nbsp; The standard level of python access is currently limited to geoprocessing tools.&amp;nbsp; In ArcGIS 10 with the arcpy.mapping the ability to work with map documents and layer files might provide the ability to do what you want.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Perhaps if you explained exactly what you need your script to accomplish there might be a way to replicate the functionality with python outside of an open map document.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 27 May 2010 18:43:28 GMT</pubDate>
    <dc:creator>JoelCalhoun</dc:creator>
    <dc:date>2010-05-27T18:43:28Z</dc:date>
    <item>
      <title>Problem Converting VBA Script to Python</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/problem-converting-vba-script-to-python/m-p/583794#M19304</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I'm trying to learn Python and am struggling to change the following VBA code to Python. Obviously not something for a begginer. One of my biggest struggles is understanding which modules to use. Help??!!!&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Private Sub AsbuiltCopy_Click()&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;'Opens a dialog box to specify which directory the asbuilt files will be saved to&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt; Dim pGxDialog As IGxDialog&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; Set pGxDialog = New GxDialog&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; pGxDialog.Title = "Select output folder"&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; pGxDialog.ButtonCaption = "OK"&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; pGxDialog.StartingLocation = "Catalog"&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; pGxDialog.AllowMultiSelect = False&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; Dim pBasicFilter As IGxObjectFilter&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; Set pBasicFilter = New GxFilterBasicTypes 'Filter for folders&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; Dim pFilterCol As IGxObjectFilterCollection&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; Set pFilterCol = pGxDialog&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; pFilterCol.AddFilter pBasicFilter, True&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt; Dim pEnumGxObject As IEnumGxObject&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; If (pGxDialog.DoModalOpen(Application.hWnd, pEnumGxObject)) Then&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; Dim pGxObject As IGxObject&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; Set pGxObject = pEnumGxObject.Next&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; MsgBox "The files will be saved to:" &amp;amp; vbNewLine &amp;amp; pGxObject.FullName&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; vpath = pGxObject.FullName&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; End If&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;'Will display a progress bar as the files copy&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; Dim pStatus As IStatusBar&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; Dim pProgress As IStepProgressor&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; Dim i As Long&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt; Set pStatus = Application.StatusBar&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; Set pProgress = pStatus.ProgressBar&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; pProgress.Position = 0&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; pStatus.ShowProgressBar "Copying .tiff Files...", 0, 500000, 1, True&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt; For i = 0 To 500000&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; pStatus.StepProgressBar&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; Next&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;'code for copying asbuilt records&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; Dim pMxDocument As IMxDocument&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; Dim pMap As IMap&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; Dim pActiveView As IActiveView&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; Dim pFeatureLayer As IFeatureLayer&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; Dim pFeatureClass As IFeatureClass&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; Dim pFeatureSelection As IFeatureSelection&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; Dim pFeatureCursor As IFeatureCursor&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; Dim pFeature As IFeature&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; Dim dblSectionID As String&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; Dim x As Integer&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; Dim pfeaturecounter As Integer&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; Set pMxDocument = ThisDocument&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; Set pMap = pMxDocument.FocusMap&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; Set pActiveView = pMxDocument.ActiveView&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; Set pFeatureLayer = pMxDocument.SelectedLayer 'pMap.Layer(0)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; Set pFeatureClass = pFeatureLayer.FeatureClass&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; Set pFeatureSelection = pFeatureLayer&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;'finds the layer with the selected features&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; pFeatureSelection.SelectionSet.Search Nothing, False, pFeatureCursor&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; Set pFeature = pFeatureCursor.NextFeature&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; 'checks to make sure a line feature is selected&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; If pFeatureSelection.SelectionSet.Count = 0 Then&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt; MsgBox "Please Select a line", vbCritical, "Error"&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; Else&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; 'counts the number of selected features and sets it up as the loop ending value&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; pfeaturecounter = pMap.SelectionCount&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; x = 0&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; 'begin loop&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Do Until x = pfeaturecounter&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt; 'captures information from line feature's database&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;On Error Resume Next&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; dblpathname = pFeature.Value(pFeature.Fields.FindField("ASBUILT"))&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; dblendpathname = pFeature.Value(pFeature.Fields.FindField("PLAT_SHEET"))&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; 'copies the asbuilt files to the folder previously specified&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; PathBeg = dblpathname&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; PathEnd = vpath &amp;amp; "\" &amp;amp; dblendpathname &amp;amp; ".tif"&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; FileCopy PathBeg, PathEnd&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; x = x + 1&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; Set pFeature = pFeatureCursor.NextFeature&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Loop&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;End If&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;pStatus.HideProgressBar&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;End Sub&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 27 May 2010 12:23:06 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/problem-converting-vba-script-to-python/m-p/583794#M19304</guid>
      <dc:creator>ElizabethTaylor</dc:creator>
      <dc:date>2010-05-27T12:23:06Z</dc:date>
    </item>
    <item>
      <title>Re: Problem Converting VBA Script to Python</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/problem-converting-vba-script-to-python/m-p/583795#M19305</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I don't know VBA but it appears your script will find the layer with the selected line records in an open MXD and copy them.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Unless you can do advance python scripting using com components to work with ArcObjects there is not a way to replicate the same functionality you are wanting.&amp;nbsp; The standard level of python access is currently limited to geoprocessing tools.&amp;nbsp; In ArcGIS 10 with the arcpy.mapping the ability to work with map documents and layer files might provide the ability to do what you want.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Perhaps if you explained exactly what you need your script to accomplish there might be a way to replicate the functionality with python outside of an open map document.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 27 May 2010 18:43:28 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/problem-converting-vba-script-to-python/m-p/583795#M19305</guid>
      <dc:creator>JoelCalhoun</dc:creator>
      <dc:date>2010-05-27T18:43:28Z</dc:date>
    </item>
    <item>
      <title>Re: Problem Converting VBA Script to Python</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/problem-converting-vba-script-to-python/m-p/583796#M19306</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;You are correct in what the script does.&amp;nbsp; What I need is this:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;1. Select a line&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;2. Read the selected line's attribute in a field (record #)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;3. Go find the record # in a file folder (the record #'s TIFF image)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;4. Copy the record # (TIFF image) into a different folder (be able to select the folder or create a new one)&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I haven't been able find Python code for selecting a line within an MXD - not by a location or attribute, but by using the Feature Selection tool.&amp;nbsp; I might be able to figure out the rest, but it sounds to me that your statement is saying that unless an ArcObject already exists to perform the task, I need to be able to do advance Python scripting with com to get this script to work in ArcGIS 10.&amp;nbsp; I'm hoping arcpy.mapping offers the ability to do this, but without having Arcgis 10 yet, I'm not able to know.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 28 May 2010 15:43:01 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/problem-converting-vba-script-to-python/m-p/583796#M19306</guid>
      <dc:creator>ElizabethTaylor</dc:creator>
      <dc:date>2010-05-28T15:43:01Z</dc:date>
    </item>
    <item>
      <title>Re: Problem Converting VBA Script to Python</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/problem-converting-vba-script-to-python/m-p/583797#M19307</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Using Python and the Geoprocessor from ArcGIS Desktop 9.3(.1) allows you to do "easily" whatever you can do using the Desktop toolbox, and a little more regarding access to the internal data structures. So if you know exactly how you would do something with the toolbox, or if you want to access a table, a feature class, etc, element by element, it is likely that you will be able to do it using basic Python+Geoprocessor in a quite straightforward manner. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;If what you want to do is outside of this scope on the GIS side, it is likely that you will have to dig deeper into the Arc' layers and use ArcObjects. The chunk of knowledge that you will need to use it in Python is much bigger/heavier than what is required for using the simpler (Desktop-) Geoprocessor.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;That said, I never did specifically what you are trying to do I guess, so I don't know which of the Geoprocessor or ArcObjects you will need to use. Hopefully a further post will give you this information.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Cheers,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Cedric&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 28 May 2010 21:39:36 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/problem-converting-vba-script-to-python/m-p/583797#M19307</guid>
      <dc:creator>CedricWannaz</dc:creator>
      <dc:date>2010-05-28T21:39:36Z</dc:date>
    </item>
  </channel>
</rss>

