def updateParameters(): if self.params[0].value: # get dict of county names and codes counties = {} rows = arcpy.SearchCursor(self.params[0].value,"","","CNAME;CCODE") for row in rows: nm = row.getValue("CNAME") cd = row.getValue("CCODE") counties[nm] = cd del row, rows # set up picklist (filter) of county names cnames = counties.keys() self.param[2].filter.list = sorted(cnames) # set up picklist of place names for this county if self.params[1].value and self.params[2].value: county_code = counties[self.params[2].value] where = "CCODE = {0}".format(county_code) rows = arcpy.SearchCursor(self.params[1].value,"",where,"PNAME;CCODE") pnames = [] for row in rows: pnames.append(row.getValue("PNAME")) del row, rows pnames = sorted(set(pnames)) # uniqueize and sort self.params[3].filter.list = pnames
I am not sure how to include Curt's code into the Tool Validator.
#Import modules import os import sys import arcpy #Set Map Document mxd = arcpy.mapping.MapDocument("Current") #Set Overwrite Option arcpy.env.overwriteOutput = True #Sets parameters (attributes) County = sys.argv[1] Place = sys.argv[2] CountyName = sys.argv[3] PlaceName = sys.argv[4] Office = sys.argv[5] Forester = sys.srgv[6] Activity = sys.argv[7] Persons = sys.argv[8] Underserverd = sys.argv[9] NameLast = sys.argv[10] NameFirst = sys.argv[11] #Create a new row and fill in fields rows = arcpy.InsertCursor("CommunityLevelActivity") row = rows.newRow() row.TFSOffice = Office row.TFSForester = Forester row.Activity = Activity row.RecipientLast = NameLast row.RecipientFirst = NameFirst row.Persons = Persons row.Underserved = Underserved row.Place = PlaceName rows.insertRow(row) del row del rows #Calculate Date Field expression = datetime.datetime.now() arcpy.CalculateField_management("CommunityLevelActivity", "DateComplete", expression, "PYTHON_9.3") # Refresh map to show all changes arcpy.RefreshActiveView() mxd.save() # Refresh map to show all changes arcpy.RefreshActiveView() mxd.save() del mxd,
Could you clarify where and how [validation] code gets applied?
Aangemelde leden kunnen berichten plaatsen, updates volgen en meer. Nieuw hier? Registreer een gratis account.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.