Is there a way to fix a broken data source on a route event layer?

4673
3
01-16-2015 01:36 PM
DamianHouseknecht
New Contributor II

So I've been trying to find a way to fix a broken data source on a route event layer within an mxd using python.  Everything I've tried doesn't seem to work.  The normal code using findAndReplaceWorkspacePath seems to work on everything but event layers.  I can recreate the event layer and import symbology from the broken layer but when I try to copy and paste parameters in the label manager, I can't copy from the broken layer because it does not show up in the layer classes list.  So...instead of create new, copy symbology, copy labeling parameters (which I can't do anyways), it would be nice if I could manipulate just the datasource via python.

Can anyone point me in the right direction?

Thanks in advance!

0 Kudos
3 Replies
MichaelMiller2
Occasional Contributor III

I've asked this same question to ESRI support and it's not possible. Since event layers are actually stored in the MXD, they are treated as temporary data.  They have to be manually updated to fix the broken links.

DamianHouseknecht
New Contributor II

Thanks for that info, I guess in my situation, the underlying issue with fixing them manually is that we use OBJECTID field as our unique identifier for routes (Gasp!!!  I know...lock me away and throw away the key!).  This is not an issue with the make route event tool because you can type it in as your route identifier (it's excluded from the drop down list in the dialog) however when you go to re-source the broken link, you only get the drop down option.  There is no way to type in OBJECTID.

It wouldn't be such a pain if my layer didn't have 15+ label classes each with their own SQL statement and expressions.

ESRI, if anyone is reading, this would be a great enhancement.  Either don't limit the dropdown list or allow some form of advanced modification capability (both would be nice actually).

0 Kudos
MichaelStead
Occasional Contributor III

Been struggling with this for a while with repathing in-map event layers, some with broken links, some from odc connections. I have observed some very interesting behaviour... but basically I think it comes down to that the dataSource value returned from an event them is not tied to the actual data source as it should be.... and even if it was it does not have parameters to redefine the coordinate fields. You should be able to create a standalone layer file on disk and do a loop though your mxds to add this. My problem with this is that I then need to remove the old layer and update all the legends...or leave the old layer in the maps, delete the old source table and live with the remnant unlinked data source in each project. You could do this all with python..or there is a "MXD and LYR Management Tools.tbx" somewhere on here that you could download for some scripttools that you could run in batch.
As for your ObjectID thing... you should make a new field..calc your values over and base you new layer file on that..a meaningless field is better than that potential wreck.

0 Kudos