Select to view content in your preferred language

Remove joins with Pro using arcpy

1178
3
06-16-2021 03:49 AM
mody_buchbinder
Frequent Contributor

I am trying to remove joins from a layer using arcpy.

When I type in the python window the line:

arcpy.management.RemoveJoin("lyr1")

it works fine and the layer in the TOC does not have joins any more.

Then I tried in python that runs from a tool:

map1 = arcpy.mp.ArcGISProject("current").listMaps()[2]
lyr = map1.listLayers()[0]
arcpy.management.RemoveJoin(lyr)

It does not return any error but does not work (joins still exists).

Then I understood that I need to take the result from the tool:

updateLayer = arcpy.management.RemoveJoin(lyr)[0]

It is working but then I have to try to insert the layer to the original position (it is not 0 as my example it is inside some groups) and remove the original.

Is there any simple way to make it works in one command just like when I type it in the python window?

Thanks

0 Kudos
3 Replies
NABAZGHARIBMOHAMMED
Occasional Contributor

after remove join, refresh TOC, see if it works.

arcpy.RefreshTOC()
0 Kudos
mody_buchbinder
Frequent Contributor

I do not see this method in Pro

0 Kudos
NABAZGHARIBMOHAMMED
Occasional Contributor

what do you mean by


@mody_buchbinder wrote:

I do not see this method in Pro

0 Kudos