Python ToolBox

Arcview GIS 3.x, Arcinfo Workstation, Mapobjects
Ответить
FreTFuL
Новоприбывший
Сообщения: 1
Зарегистрирован: 15 апр 2013, 23:29
Репутация: 0

Python ToolBox

Сообщение FreTFuL » 15 апр 2013, 23:37

Код: Выделить всё

from arcpy.sa import *


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

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


class Tool(object):
    def __init__(self):
        """Define the tool (tool name is the name of the class)."""
        self.label = "Tool"
        self.description = ""
        self.canRunInBackground = False

    def getParameterInfo(self):
        param0 = arcpy.Parameter(
            displayName = "Input value",
            name = "in_value",
            datatype = "GPFeatureLayer",
            parameterType = "Required",
            direction = "input")
        """Define parameter definitions"""
        params = [param0]
        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
Не запускается пишет
Traceback (most recent call last): File "<string>", line 28, in getParameterInfo File "c:\program files\arcgis\desktop10.1\arcpy\arcpy\arcobjects\mixins.py", line 286, in __init__ setattr(self, attrib, attribvalue) File "c:\program files\arcgis\desktop10.1\arcpy\arcpy\arcobjects\_base.py", line 87, in _set return setattr(self._arc_object, attr_name, cval(val))ValueError: ParameterObject: Invalid input value for DataType property
Хотя если тип поставить String все работает. Помогите пожалуйста.

doujin
Активный участник
Сообщения: 163
Зарегистрирован: 28 июн 2012, 01:02
Репутация: 84
Откуда: Vladivostok

Re: Python ToolBox

Сообщение doujin » 17 апр 2013, 03:26

Приведенный вами код на английской ArcGIS 10.1 SP1 работает без ошибок. Возможно, проблема не в коде.

Ответить

Вернуться в «Arcview GIS»

Кто сейчас на конференции

Сейчас этот форум просматривают: нет зарегистрированных пользователей и 3 гостя