updateConnectionProperties is breaking all other layers

409
2
03-06-2021 11:50 AM
JeremyMoore2
New Contributor II

I have an issue that has me pretty stumped. I'm writing a script that is taking powerline information, replacing a layers source data in a map, kicking out a new aprx then creating tile packages from the aprx. 

What's happening is that when updateConnectionProperties is fired off on the conductor layer, its breaking all the other layers and their source data. 

Has any one else experienced this before? 

I have included the section of my script below:

 

arcpy.env.workspace = circuitGDB
aprx = arcpy.mp.ArcGISProject(aprxFile)

for featureClasses in arcpy.ListFeatureClasses():

    #print(featureClasses)

    for map in aprx.listMaps():
        if map.name == "Layers":
            for layers in map.listLayers():
                #print(map.name)
                #print(layers)
                
                if str(layers) == "Conductor":
                    print("Found The Conductor Layer")
                    print("\nThe original connection properties is:")

                    connDict = {'connection_info': {'database': circuitGDB},
                                'dataset': featureClasses,
                                'workspace_factory': 'File Geodatabase'}
                    
                    currConnProp = layers.connectionProperties
                    pprint.pprint(currConnProp)

                    layers.updateConnectionProperties(current_connection_info=currConnProp,
                                                      new_connection_info=connDict)
                    
                    aprx.saveACopy(editedAPRXFileLoc + "\\" + featureClasses + ".aprx")

                    print("Updated the Datat Source and saved new aprx for circuit : ")
                    print(featureClasses)
                    print("----------------------------------------------------------------")

 

Tags (2)
0 Kudos
2 Replies
MichaelVolz
Esteemed Contributor

Are you trying to update the connection properties of the other layers in the aprx or are they supposed to be left intact?

0 Kudos
DavidPike
MVP Frequent Contributor

What is ListFeatureClasses() doing, and subsequent loop?

0 Kudos