I am trying to change the data source geodatabase of ArcGIS Pro layers. The feature class name is unchanged.
It is the general consensus to use connectionProperties for this, however I have a number of feature classes that do not have connectionProperties so I've elected to use CIM for these.
if hasattr(layr,'connectionProperties'):
Returns False.
For the CIM, If I just write:
lyrCIM = layr.getDefinition('V2')
layr.setDefinition(lyrCIM)
It throws an error! The error message is the line number. Ugh.
What I want to do is:
lyrCIM = layr.getDefinition('V2')
dc = lyrCIM.featureTable.dataConnection
dc.workspaceConnectionString = f"DATABASE={newdb}"
layr.setDefinition(lyrCIM)
Which throws the same (useless) error.
My ArcGIS Pro version is 2.9.5