AnsweredAssumed Answered

Cannot pass output from custom function in a script

Question asked by LANDVEST on Sep 22, 2017
Latest reply on Sep 25, 2017 by mitchh300

I have a function that creates a sample point grid within a polygon (simple). I'm calling it up in a script to loop through a number of inputs to create multiple sample point grids. This works as expected but overwrites the output of each iteration. So I'd like to append the result from each input in the loop to a target. However, the script 'doesn't know' the output of the function (even though it exists).

Clear as mud? I'll add the (parent) script as code and the (child) function as an attachment.

In the Python Window:

with arcpy.da.SearchCursor("TESTSTANDS", fields) as cursor:
...     for row in cursor:
...         space = row[0]
...         arcpy.SelectLayerByAttribute_management("TESTSTANDS","NEW_SELECTION","OBJECTID = {}".format(row[1]))
...         Create_Grid_test.createGrid("TESTSTANDS",space,space)
...         arcpy.Append_management(outPoints,r'd:\temp\plotdump.shp',"NO_TEST","","")

This gives the following error:

Runtime error 
Traceback (most recent call last):
  File "<string>", line 6, in <module>
NameError: name 'outPoints' is not defined

When using the same function as a Script Tool, its easy to define 'outPoints' as a derived output...but here I'm at a loss.


Thanks in advance, and my apologies with my feeble understanding of correct terminology with Python objects. Please let me know if I have to provide more detail!