complex Stage Service

155
0
12-10-2019 04:32 AM
CliveSwan
Occasional Contributor II

The Stage Service example is great for a simple project.

https://pro.arcgis.com/en/pro-app/tool-reference/server/stage-service.htm#C_GUID-E4EE691D-C5C2-4F1C-...
# Reference map to publish
aprx = arcpy.mp.ArcGISProject(r"C:\Project\World.aprx")
m = aprx.listMaps("World")[0]
lyrs = []
lyrs.append(m.listLayers('cities')[0])
lyrs.append(m.listLayers('counties')[0])

If you have a complex project with thirty or more Layers included, do you really have to hardcode all thirty layers??

I have tried to update this using:

    aprx = arcpy.mp.ArcGISProject(r"C:\apps\APP10\Maps\APR\Map_All_Utilities.aprx")
    m = aprx.listMaps("*")[0]
   
    water_lyrs = ['Water']
    water_lyr = ['']
    steam_lyrs = ['Steam']
    steam_lyr = ['']

     
    water_lyrs.append(m.listLayers(water_lyr)[0])
    for a in water_lyrs():
        print(a)
        water_lyrs.append(m.listLayers(a)[0])

The error is  

Error: list index out of range

Any suggestions??

0 Kudos
0 Replies