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??!!!
Private Sub AsbuiltCopy_Click()
'Opens a dialog box to specify which directory the asbuilt files will be saved to
Dim pGxDialog As IGxDialog
Set pGxDialog = New GxDialog
pGxDialog.Title = "Select output folder"
pGxDialog.ButtonCaption = "OK"
pGxDialog.StartingLocation = "Catalog"
pGxDialog.AllowMultiSelect = False
Dim pBasicFilter As IGxObjectFilter
Set pBasicFilter = New GxFilterBasicTypes 'Filter for folders
Dim pFilterCol As IGxObjectFilterCollection
Set pFilterCol = pGxDialog
pFilterCol.AddFilter pBasicFilter, True
Dim pEnumGxObject As IEnumGxObject
If (pGxDialog.DoModalOpen(Application.hWnd, pEnumGxObject)) Then
Dim pGxObject As IGxObject
Set pGxObject = pEnumGxObject.Next
MsgBox "The files will be saved to:" & vbNewLine & pGxObject.FullName
vpath = pGxObject.FullName
End If
'Will display a progress bar as the files copy
Dim pStatus As IStatusBar
Dim pProgress As IStepProgressor
Dim i As Long
Set pStatus = Application.StatusBar
Set pProgress = pStatus.ProgressBar
pProgress.Position = 0
pStatus.ShowProgressBar "Copying .tiff Files...", 0, 500000, 1, True
For i = 0 To 500000
pStatus.StepProgressBar
Next
'code for copying asbuilt records
Dim pMxDocument As IMxDocument
Dim pMap As IMap
Dim pActiveView As IActiveView
Dim pFeatureLayer As IFeatureLayer
Dim pFeatureClass As IFeatureClass
Dim pFeatureSelection As IFeatureSelection
Dim pFeatureCursor As IFeatureCursor
Dim pFeature As IFeature
Dim dblSectionID As String
Dim x As Integer
Dim pfeaturecounter As Integer
Set pMxDocument = ThisDocument
Set pMap = pMxDocument.FocusMap
Set pActiveView = pMxDocument.ActiveView
Set pFeatureLayer = pMxDocument.SelectedLayer 'pMap.Layer(0)
Set pFeatureClass = pFeatureLayer.FeatureClass
Set pFeatureSelection = pFeatureLayer
'finds the layer with the selected features
pFeatureSelection.SelectionSet.Search Nothing, False, pFeatureCursor
Set pFeature = pFeatureCursor.NextFeature
'checks to make sure a line feature is selected
If pFeatureSelection.SelectionSet.Count = 0 Then
MsgBox "Please Select a line", vbCritical, "Error"
Else
'counts the number of selected features and sets it up as the loop ending value
pfeaturecounter = pMap.SelectionCount
x = 0
'begin loop
Do Until x = pfeaturecounter
'captures information from line feature's database
On Error Resume Next
dblpathname = pFeature.Value(pFeature.Fields.FindField("ASBUILT"))
dblendpathname = pFeature.Value(pFeature.Fields.FindField("PLAT_SHEET"))
'copies the asbuilt files to the folder previously specified
PathBeg = dblpathname
PathEnd = vpath & "\" & dblendpathname & ".tif"
FileCopy PathBeg, PathEnd
x = x + 1
Set pFeature = pFeatureCursor.NextFeature
Loop
End If
pStatus.HideProgressBar
End Sub