Programmatically reset layer IDs in Pro

1420
5
08-08-2022 09:37 AM
Labels (1)
amallen
Emerging Contributor

We have several users in our group who create ArcGIS Pro projects and a colleague & I are responsible for publishing them as map services to one of our Portals. There are occasions when our Pro authors copy and paste layers in the project, creating duplicate layer IDs, or move layers around in the project. Is there an ArcPy method where we can auto-generate new layer IDs starting from the first layer in the list (i.e.: 0 to N -1 layers)? It does not matter that we wipe out and re-set the layer IDs in the corresponding map services. Thanks.

5 Replies
AdrianMarsden
Honored Contributor

No idea -  I was going to post the same question, but this popped up.  With over 300 layers in a project when I paste one in from a new project it is very hard to work out the next number to add.

RhettZufelt
MVP Notable Contributor

No idea either.  But for the copy/paste of layers, if you  enable the "Allow assignment of unique numeric IDs for sharing web layer" before you paste it, it will automatically update the layer ID to a unique value.  Without this checked, it will retain the value of the layer being copied.

RhettZufelt_0-1678977783727.png

 

R_

ChelseaRozek
MVP Regular Contributor

I've been looking for this too. Looks like it's not built in yet, but you can access it through the CIM: https://community.esri.com/t5/arcgis-api-for-python-questions/assign-layer-ids-using-arcpy/m-p/13627...

AdrianMarsden
Honored Contributor

Even a simple right click on the layer ID box in Properties with "Assign next free ID"  would be great as when we copy layers from one project to another it will keep the old IID - finding the next free ID involves add a single new layer, finding that ID, removing that layer and using that ID for the pasted one.

The routine must be inside Pro to call when you add a new layer

AdrianMarsden
Honored Contributor

...or the other option is when you paste layers in from another project you get an option to retain ID or assign them automatically

0 Kudos