progressor bar occasionally freezes in arcpy

115
1
Jump to solution
2 weeks ago
JAYAKUMARKUMAR
Emerging Contributor

Hi,

I am using the following code to process datasets and feature classes from a source geodatabase and apply edits to a destination SDE feature class using arcpy.da.Editor


The progressor bar occasionally freezes or doesn't update correctly during the dataset and feature class processing, which makes it hard to monitor the progress of the script.

 

 

 

 

0 Kudos
1 Solution

Accepted Solutions
SumitMishra_016
Frequent Contributor

Hi @JAYAKUMARKUMAR 

The arcpy.SetProgressorPosition() is called after each processed feature class, avoiding freezing or incorrect updates.
Please try like this in your script:

 

# Set the progressor
arcpy.SetProgressor("step", "Copying shapefiles to geodatabase...",
                    0, fc_count, 1)

# Create a file gdb to contain new feature classes
arcpy.CreateFileGDB_management(arcpy.env.workspace, "fgdb.gdb")

# For each shapefile, copy to a file geodatabase
for shp in fcs:
    # Trim the '.shp' extension
    fc = os.path.splitext(shp)[0]

    # Update the progressor label for current shapefile
    arcpy.SetProgressorLabel("Loading {0}...".format(shp))

    # Copy the data
    arcpy.CopyFeatures_management(shp, os.path.join("fgdb.gdb", fc))

    # Update the progressor position
    arcpy.SetProgressorPosition()

arcpy.ResetProgressor()



https://pro.arcgis.com/en/pro-app/latest/arcpy/functions/resetprogressor.htm 

 

View solution in original post

1 Reply
SumitMishra_016
Frequent Contributor

Hi @JAYAKUMARKUMAR 

The arcpy.SetProgressorPosition() is called after each processed feature class, avoiding freezing or incorrect updates.
Please try like this in your script:

 

# Set the progressor
arcpy.SetProgressor("step", "Copying shapefiles to geodatabase...",
                    0, fc_count, 1)

# Create a file gdb to contain new feature classes
arcpy.CreateFileGDB_management(arcpy.env.workspace, "fgdb.gdb")

# For each shapefile, copy to a file geodatabase
for shp in fcs:
    # Trim the '.shp' extension
    fc = os.path.splitext(shp)[0]

    # Update the progressor label for current shapefile
    arcpy.SetProgressorLabel("Loading {0}...".format(shp))

    # Copy the data
    arcpy.CopyFeatures_management(shp, os.path.join("fgdb.gdb", fc))

    # Update the progressor position
    arcpy.SetProgressorPosition()

arcpy.ResetProgressor()



https://pro.arcgis.com/en/pro-app/latest/arcpy/functions/resetprogressor.htm