AnsweredAssumed Answered

How can I force a python toolbox to refresh?

Question asked by BIU-Management on Aug 13, 2014
Latest reply on Jun 17, 2015 by bdaigle

In order to ease the entry of the parameters, whenever the toolbox is opened, the latest parameters are being read from a table, and if changed are saved back. The problem is that the toolbox must be manually refreshed every time for the parameters to be displayed correctly.

 

def getParameterInfo(self):

cursor = arcpy.da.SearchCursor("Parameters", ['data_set', 'date_p', 'from_p', 'to_p', 'location_p', 'wait_p', 'distance_p'])

for row in cursor:

  ds=row[0]

  date_p=row[1]

  from_p=row[2]

  to_p=row[3]

  location_p=row[4]

  wait_p=row[5]

  distance_p=row[6]

  l_ds="results-"+ds

param0 = arcpy.Parameter(

  displayName="Destinations",

  name="in_destinations",

  datatype="GPString",

  parameterType="Required",

  direction="Input")

param0.filter.type = "ValueList"

values = [row[0] for row in arcpy.da.SearchCursor(l_ds, ("location"))]

param0.value=location_p

lst = list(set(values))

lst.sort()

param0.filter.list = lst

.

.

.

 

def execute(self, parameters, messages):

arcpy.env.workspace =""

location_p=parameters[0].valueAsText

date_p=parameters[1].valueAsText

from_p=parameters[2].valueAsText

to_p=parameters[3].valueAsText

wait_p=parameters[4].valueAsText

distance_p=parameters[5].valueAsText

cursor = arcpy.da.UpdateCursor("Parameters", ['date_p', 'from_p', 'to_p', 'location_p', 'wait_p', 'distance_p'])

for row in cursor:

  row[0]=date_p

  row[1]=from_p

  row[2]=to_p

  row[3]=location_p

  row[4]=wait_p

  row[5]=distance_p

  cursor.updateRow(row)

.

.

.

Outcomes