1

I have script that should add lyr file from server. It is like a multiple symbology to certain layerin TOC, i.e. I have a feature class called tline and different symbology layers like tlineA, tlineB. My goal is to have independent tline layer and upload tlineA and tlineB layers to TOC and change their data sources. I made a script tool that already can read paths to tline and tlineA, tlineB and should change the data source of tlineA

Here is it

ab = arcpy.Describe("tline")
path = ab.path
ao = arcpy.Describe("tlineA")
peth=ao.path

for lyr in arcpy.mapping.ListLayers(mxd, "",df):
     if lyr.name == "tlineA":
         lyr.findAndReplaceWorkspacePath (peth,path)
         print lyr.dataSource

But anyway the datasource of tlineA remains the same as it was before. I also tried like

lyr.findAndReplaceWorkspacePath (r"ao",r"ab")

But still doesn't work.

closed as unclear what you're asking by PolyGeo Jan 11 '17 at 7:51

Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

  • @GISGe corrected – Pavel Pereverzev Nov 24 '16 at 14:14
  • 1
    Can you show more of your script? Does mxd reference the currently open mxd, or an mxd on your disk? – GISGe Nov 24 '16 at 14:16
  • If this is a Python script tool, does it have any parameters? What do you mean when you say "doesn't work"? – PolyGeo Nov 24 '16 at 14:22
  • @GISGe added full script – Pavel Pereverzev Nov 24 '16 at 14:23
  • @PolyGeo it doesn't have parameters I want just to import symbology layers to TOC with a reference to initial tline layer which can be taken from any gdb file. – Pavel Pereverzev Nov 24 '16 at 14:24

Browse other questions tagged or ask your own question.