Last active
October 28, 2015 23:15
-
-
Save phobson/affdf80db837e7786391 to your computer and use it in GitHub Desktop.
Arcpy docs are still terrible (http://resources.arcgis.com/en/help/main/10.2/index.html#/Parameter/018z00000063000000/)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"cells": [ | |
{ | |
"cell_type": "code", | |
"execution_count": 1, | |
"metadata": { | |
"collapsed": true | |
}, | |
"outputs": [], | |
"source": [ | |
"import arcpy\n", | |
"\n", | |
"class Flooder(object):\n", | |
" def __init__(self):\n", | |
" self.label = \"1 - Create Flood Scenarios\"\n", | |
" self.description = \"\"\n", | |
" self.canRunInBackground = True\n", | |
" \n", | |
" def isLicensed(self):\n", | |
" return True\n", | |
"\n", | |
" def updateParameters(self, parameters): \n", | |
" polygons = parameters[0]\n", | |
" tgcol = parameters[1]\n", | |
" try:\n", | |
" print(\"using list of integers\")\n", | |
" polygons.parameterDependencies = [1]\n", | |
" except:\n", | |
" print(\"that failed, try a list integers as strings\")\n", | |
" polygons.parameterDependencies = [\"1\"]\n", | |
" print(\"yup that worked #slowclap\")\n", | |
" \n", | |
"\n", | |
" def getParameterInfo(self):\n", | |
" polygons = arcpy.Parameter(displayName=\"Zones\", name=\"polygons\",\n", | |
" datatype=\"DEFeatureClass\", parameterType=\"Required\", \n", | |
" direction=\"Input\")\n", | |
"\n", | |
" tidegate_column = arcpy.Parameter(displayName=\"ID column\", name=\"tidegate_column\",\n", | |
" datatype=\"Field\", parameterType=\"Required\", \n", | |
" direction=\"Input\")\n", | |
"\n", | |
" return [polygons, tidegate_column]\n" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 2, | |
"metadata": { | |
"collapsed": false | |
}, | |
"outputs": [ | |
{ | |
"name": "stdout", | |
"output_type": "stream", | |
"text": [ | |
"using list of integers\n", | |
"that failed, try a list integers as strings\n", | |
"yup that worked #slowclap\n" | |
] | |
} | |
], | |
"source": [ | |
"f = Flooder()\n", | |
"p = f.getParameterInfo()\n", | |
"f.updateParameters(p)" | |
] | |
} | |
], | |
"metadata": { | |
"kernelspec": { | |
"display_name": "Python 2", | |
"language": "python", | |
"name": "python2" | |
}, | |
"language_info": { | |
"codemirror_mode": { | |
"name": "ipython", | |
"version": 2 | |
}, | |
"file_extension": ".py", | |
"mimetype": "text/x-python", | |
"name": "python", | |
"nbconvert_exporter": "python", | |
"pygments_lexer": "ipython2", | |
"version": "2.7.10" | |
} | |
}, | |
"nbformat": 4, | |
"nbformat_minor": 0 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment