Change name of derived parameter output feature layer

210
2
08-07-2024 11:47 PM
AsgeirLysdahl
New Contributor

Hello, I have a python tool with a few derived output parameters, these are feature layers that gets linked to shapefiles at the end of the script, and they get a symbology:

arcpy.SetParameterAsText(32, buildings_shapefile_result)
arcpy.SetParameterSymbology(32, lyr_building_risk_a)
 
This works. However, if I try to add the same shapefile to multiple output feature layers (with different symbology), I only get one of these, probably because ArcGIS Pro cannot have several layers in Contents with the same name. Is there any way to access the feature layer's name right after the above code and change it? I tried a couple of things without success.
2 Replies
AlfredBaldenweck
MVP Regular Contributor

Pro is generally not at all averse to having several layers of the same name. It's more likely that you keep overwriting the same variable or something.

Can you post more of your code?

0 Kudos
AsgeirLysdahl
New Contributor

Thats a good point indeed, but SetParameterAsText and SetParameter seems to be void functions?

The parameter 31, 32 and 33 are defined as layer files. I assign a shapefile with walls to 31 and a shapefile with buildings to 32 and 33 which are then symbolized differently. You are probably right - something is being overwritten, but how can I change these attributes right after the SetParameter command? The walls are added correctly to the map.

if addWalls:
   arcpy.SetParameterAsText(31, walls_Shapefile_result)
   arcpy.SetParameterSymbology(31, lyr_walls)
if bVulnerability:
   if addRiskAngle:
      arcpy.SetParameterAsText(32, buildings_Shapefile_result)
      arcpy.SetParameterSymbology(32, lyr_building_risk_a)
   if addRiskSettl:
      arcpy.SetParameterAsText(33, buildings_Shapefile_result)
      arcpy.SetParameterSymbology(33, lyr_building_risk_sv)
 
Here, "building_shapefile_result" is simply a string containing the path and the name (with extension) of the shapefile. Below is a snapshot of the parameter table in the tool.
 
AsgeirLysdahl_0-1723218807640.png

 

0 Kudos