Pergunta

I'm a beginner in using Python to create Python toolboxes. I was trying to follow the instructions in this video http://www.youtube.com/watch?v=B6zbzPOnYYQ to create my first Python toolbox I have tried to create this toolbox using the code in that video (from 24:00 to 27:00). However, after writing the exact code and trying to run it, I got this error;

Traceback (most recent call last):  File "<string>", line 24,
  in getParameterInfoAttributeError: 'module' object has no attribute 'Paramter' 

The code is illustrated below

import arcpy

class Toolbox(object):
    def __init__(self):
        """Define the toolbox (the name of the toolbox is the name of the
        .pyt file)."""
        self.label = "Calculate Geomtery"
        self.alias = "Geometry"

        # List of tool classes associated with this toolbox
        self.tools = [CalculateGeometry]


class CalculateGeometry(object):
    def __init__(self):
        """Define the tool (tool name is the name of the class)."""
        self.label = "Calculate Geometry"
        self.description = ""
        self.canRunInBackground = True

    def getParameterInfo(self):
        # First parameter
    in_features = arcpy.Paramter(
        displayName="Input Features",
        name="in_features",
        datatype="Feature Layer",
        parameterType="Required",
        direction="Input")
    in_features.filter.list = ["Point", "Polyline", "Polygon"]

        # Second parameter
    field = arcpy.Paramter(
        displayName="Field Name",
        name="field_name",
        datatype="Field",
        parameterType="Required",
        direction="Input")

    field.parameterDependencies = [in_features.name]
    in_features.filter.list = ["Short", "Long", "Double", "Float", "Text"]

    # Third parameter
    geomProperty = arcpy.Paramter(
        displayName="Property",
        name="geomProperty",
        datatype="String",
        parameterType="Required",
        direction="Input")

    # Fourth parameter
    units = arcpy.Paramter(
        displayName="Units",
        name="units",
        datatype="String",
        parameterType="Optional",
        direction="Input",
        enabled=False)

    # Fifth parameter
    out_features = arcpy.Paramter(
        displayName="Output Features",
        name="out_features",
        datatype="Feature Layer",
        parameterType="Derived",
        direction="Output")

    out_features.parameterDependencies = [in_features.name]
    out_features.schema.clone = True

    params = [in_features, field, geomProperty, units, out_features]
    return params

    def isLicensed(self):
        """Set whether tool is licensed to execute."""
        return True

    def updateParameters(self, parameters):
        """Modify the values and properties of parameters before internal
        validation is performed.  This method is called whenever a parameter
        has been changed."""
        return

    def updateMessages(self, parameters):
        """Modify the messages created by internal validation for each tool
        parameter.  This method is called after internal validation."""
        return

    def execute(self, parameters, messages):
        """The source code of the tool."""
        return

Any help would be much appreciated

Foi útil?

Solução

From your error message and the documentation, I think you misspelled the word.

It should be: arcpy.Parameter(parameters)

Sorry I could have left a comment, but don't have enough reputation.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top