Hi
I am creating a script tool based on a python script.
I have come so far that layers are added to the map using the arcpySetParameterAsText.
The challenge is to control the layer names appearing in the TOC of ArcMap when the tool is run from ArcMap.
I have tried to do something like the below in the python script where the parameters post-fixed with 'Layer' are defined strings earlier in the script:
It does not seem like this part of the script is doing much at all when run as a script tool.
Would an option be to do this in the toolvalidation, and if so, would you have any suggestion on how to do it?
Any help is appreciated:)
Kind Regards
Hallstein
I am creating a script tool based on a python script.
I have come so far that layers are added to the map using the arcpySetParameterAsText.
The challenge is to control the layer names appearing in the TOC of ArcMap when the tool is run from ArcMap.
I have tried to do something like the below in the python script where the parameters post-fixed with 'Layer' are defined strings earlier in the script:
Code:
map = arcpy.mapping.MapDocument("CURRENT")
layers = arcpy.mapping.ListLayers(map)
for layer in layers:
if layer.name == horizonGridFile:
layer.name = horizonLayer
if layer.name == horizonGridDipFile:
layer.name = horizonDipLayer
if layer.name == horizonContourFile:
layer.name = horizonContourLayer
arcpy.RefreshTOC()
Would an option be to do this in the toolvalidation, and if so, would you have any suggestion on how to do it?
Any help is appreciated:)
Kind Regards
Hallstein