Select to view content in your preferred language

ArcGIS Pro 3 Update Connection Properties

730
2
07-10-2023 09:24 PM
GeoNZ
by
Occasional Contributor

Hi Community,

I have seen numerous threads on this process but seemingly all the results I have found I have come up empty to where the last user posted a few months ago and was resulting to manually changing data.
https://community.esri.com/t5/arcgis-api-for-python-questions/updating-data-source-in-arcgis-pro-pro...

I have code that worked perfectly fine in Pro 2.9.6, However with the upgrade to 3 a lot of headaches are being caused.

I have a process that creates new features, populates a FGDB and then "should" re-path to the new data in the new FGDB. Obviously the variables below are defined in prior code.

# Update the layer path to the newly created data.

for lyr in mf.map.listLayers():
cp = lyr.connectionProperties # Returns a python dictionary of connection properties.
if lyr.name == "Lines":
arcpy.AddMessage("Updating source for %s to %s" %(lyr.name,out_Lines))
cp['dataset'] = out_Lines
cp['connection_info'] = {'database': str(gdbPathFinal)}
lyr.updateConnectionProperties(lyr.connectionProperties,cp,True,True)
if lyr.name == "Polygons":
arcpy.AddMessage("Updating source for %s" %(lyr.name))
cp['dataset'] = out_Poly
cp['connection_info'] = {'database': str(gdbPathFinal)}
lyr.updateConnectionProperties(lyr.connectionProperties,cp,True,True)
# Pan the map to the output. Maintaining current scale. 
mf.panToExtent(mf.getLayerExtent(lyr)) #Set dataframe extent.
if lyr.name == "Points":
arcpy.AddMessage("Updating source for %s" %(lyr.name))
cp['dataset'] = out_Points
cp['connection_info'] = {'database': str(gdbPathFinal)}
lyr.updateConnectionProperties(lyr.connectionProperties,cp,True,True)

It fails on the "cp = lyr.connectionProperties # Returns a python dictionary of connection properties."

AttributeError: The attribute 'connectionProperties' is not supported on this instance of Layer.

Has the layer properties configuration changed between versions?


Is someone able to shed some light why this will not work in ArcGIS Pro 3 as I havent been able to find specific documentation referring to any changes in this methodology between 2.9.x an 3

Apologies if this is a simple fix!
Thanks!

0 Kudos
2 Replies
DanPatterson
MVP Esteemed Contributor
AlfredBaldenweck
MVP Regular Contributor

Make sure to filter out Group and Basemap layers before trying to replace datasources.