Select to view content in your preferred language

Changing the data source of an annotation layer/joined table in ArcMap with Python

313
0
11-25-2013 07:43 AM
RichardLesperance
Emerging Contributor
Hey everyone; since ESRI is forcing us to go with Direct Connects on SDE, I'm tasked with writing a script that repairs map documents so the layers are connected to their source via direct connection instead of a service connection.
So I created a python script that uses the layer.replaceDataSource for each layer in the map.

if lyr.supports("SERVICEPROPERTIES"):
servProp = lyr.serviceProperties

serviceType = servProp.get('ServiceType', 'N/A')
if serviceType == "SDE" and servProp.get('Service', 'N/A') <> 'sde:sqlserver:SDESERVER':
dbaseName = servProp.get('Database', 'N/A')
print dbaseName + ": Service=" + servProp.get('Service', 'N/A')

if dbaseName == "geo_data":
lyr.replaceDataSource("J:\GIS\ArcMapResources\SDEConnectionFiles\LocalData.sde", "SDE_WORKSPACE", "Geo_Data.SDE." + lyr.name)

The LocalData.sde file is the same connection file that people used originally to get the data for their maps. I just changed the connection type in the Connection Properties of this file to be a direct connection instead of a service connection.

The problem is that database annotation layers don't respond to this method. Is there a method or tool that re-points connections for annotation layers?

Also, some of our layers are feature classes joined to SQL Server database tables or views. I can fix the data source of the feature class, but the joined table doesn't fix. Is there a way to use Python to fix that connection?
Thanks

Richard
Tags (2)
0 Kudos
0 Replies