2

I am using ArcGIS Pro.

I want to make a Python toolbox tool (*.pyt) where I put for input multiple layer's and to apply a buffer for every input. I want every buffer to put another distance. After I put the input layer's to appear another window where to specify the distance for buffer.

Is it possible?

def getParameterInfo(self):
    """Define parameter definitions"""
    Layers=arcpy.Parameter(
        displayName="Layers",
        name="Layer",
        direction="Input",
        parameterType="Required",
        datatype="GPFeatureLayer",
        multiValue="True")
    parameter = [Layers]
    return parameter

def execute(self, parameter, messages):
    """The source code of the tool."""
    parameter=params[0].valueAsText

enter image description here

5
  • 2
    If you are creating a python toolbox then you want to create a value table parameter to capture layer/distance combinations.
    – Hornbydd
    Commented Jun 11, 2022 at 19:54
  • 1
    Are you writing a Python script tool (tbx) or Python Toolbox tool (pyt)?
    – PolyGeo
    Commented Jun 11, 2022 at 21:27
  • A Python Toolbox tool (pyt)
    – Octav
    Commented Jun 12, 2022 at 12:18
  • 2
    Please don't respond to requests for additional information as a comment, edit your question to include the info.
    – user2856
    Commented Jun 12, 2022 at 13:06
  • Could you please provide the def execute part of the code as well? I've been struggling with the same issue. I have multiple layers with different buffer distances and I want to get multiple outputs with the different buffers. Commented Oct 14, 2022 at 15:50

1 Answer 1

2

The following sets up a value table in a python toolbox which takes layers and allows you to set distances that would feed into a buffer tool.

def getParameterInfo(self):
    """Define parameter definitions"""
    p0 =arcpy.Parameter(displayName="Layers",name="Layer",direction="Input",parameterType="Required",datatype="GPValueTable",multiValue="True")
    p0.columns = [["GPFeatureLayer", "Layers"], ["GPLong", "Buffer Distance"]] # Defines the structure of the table
    p0.filters[0].list = ['POINT','POLYLINE'] # Limits the Featurelayers to be only point or polyline
    p0.filters[1].type = 'Range' # sets the filter on the buffer to be a range
    p0.filters[1].list = [1,100] # only buffers distances between 1 and 100 (inclusive) can be set
    params = [p0]
    return params

The interface looks like this (note error symbol as it is capturing the incorrect buffer value:

Tool interface

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.