||
一、界面搭建过程的参数设置
def __init__(self): """Define the tool (tool name is the name of the class).""" self.label = "要素续编码" self.description = "对指定的属性字段,在给定起始编码的基础上,对没有编码的属性值进行续编码。" self.canRunInBackground = False def getParameterInfo(self): """Define parameter definitions""" gdbFeatureClassPath = arcpy.Parameter( displayName=u"待编码的图层", name="gdbFeatureClassPath", datatype="GPFeatureLayer", parameterType="Required", direction="Input", # description="选择需要编码的图层。" ) fieldAttribute = arcpy.Parameter( displayName="待编码的属性字段", name="fieldAttribute", datatype="GPString", parameterType="Required", direction="Input", # description="输入需要编码的属性字段。" ) startIDNum = arcpy.Parameter( displayName="起始编码", name="startIDNum", datatype="GPString", parameterType="Required", direction="Input", ) params = [gdbFeatureClassPath, fieldAttribute, startIDNum] return params
三、参数的调用
def execute(self, parameters, messages): """The source code of the tool. C:\Users\Administrator\Desktop\TestData\ArcPython\testShp\Test.gdb\Line IDNumber ROALN20120000000014 """ inFeatureClass = arcpy.Parameter[0] # inFeatureClass = r'C:\Users\Administrator\Desktop\TestData\ArcPython\testShp\Test.gdb\Line' field = arcpy.Parameter[0].valueAsText # field = 'IDNumber' startID = arcpy.Parameter[1].valueAsText # startID = 'ROALN20120000000014' doexcute(inFeatureClass, field, startID) return
Archiver|手机版|科学网 ( 京ICP备07017567号-12 )
GMT+8, 2024-9-27 19:18
Powered by ScienceNet.cn
Copyright © 2007- 中国科学报社