arcpy - lyr in getparamter list

1346
3
Jump to solution
03-09-2021 02:23 PM
DavidCook2
New Contributor III

I have a toolbox python script that still works in ArcMap - I am trying to updated to work in ArcPro

the script takes input parameters for

1 Site Boundary

2 Layers on Site (multiple layers)

3 Layers within distance of Site (multiple layers)

and writes to a text file summarizing layers and their visible fields that fall within or within distance of Site Boundary Feature.

where it seems to be not working in ArcPro is when it selects lyrs in the map from the input parameters. the script is completing without error messages because it is not recognizing any layers in the map that are in GetParameter inputs...

WithinLyrs = arcpy.GetParameter(1)

NearbyLyrs = arcpy.GetParameter(2)

dataF = aprx.activeMap

layers = dataF.listLayers()

lyrNum=0

for lyr in layers:

>if lyr.isFeatureLayer==1

>>if lyr in WithinLyrs or NearbyLyrs:

 

how is this handled differently in Pro vs Map?

0 Kudos
1 Solution

Accepted Solutions
DanPatterson
MVP Esteemed Contributor

did you try GetParameterAsText (you have others), and move the arcpy Current line up before the parameter list (shouldn't matter, but it might.  Your layer list should be populated with the values within the project as multivalue, direction input.  Using the python custom toolbox still allows you to work with a dialog and you can modify you parameters there as well


... sort of retired...

View solution in original post

3 Replies
DanPatterson
MVP Esteemed Contributor

did you try GetParameterAsText (you have others), and move the arcpy Current line up before the parameter list (shouldn't matter, but it might.  Your layer list should be populated with the values within the project as multivalue, direction input.  Using the python custom toolbox still allows you to work with a dialog and you can modify you parameters there as well


... sort of retired...
DavidCook2
New Contributor III

Dan - thanks for the tips. GetParameterAsText and moving arcpy Current did not work - but the only reason why layers were being pulled from the map was to turn them on and make visible if they were in  the input selection. if all layers are being added to parameters as inputs from the map this is redundant and not needed. adjusted section to just look at input parameter variables. 

0 Kudos
by Anonymous User
Not applicable

thanks for the tips Dan!

0 Kudos