i have created the following tool to add two fields in a table and do a calculation in order to put the tool to ModelBuilder.
For some reason when i am going to put it as an input in an another tool it doesn't appear.
I think i have done something wrong with 1. SetParameter and also 2. i haven't managed to save it as a feature class and it's only in memory.In addition i don't have a gdb or an mxd.
Also i set set parameter as an output feature class at tool's parameters but it didn't make any difference.
I am using ArcGIS 10.2.2, any suggestion?
# Import system modules
import arcpy
from arcpy import env
arcpy.overwriteoutput = True
# Set environment settings
inWorkspace = arcpy.GetParameterAsText(0)
inFeature = arcpy.GetParameterAsText(1)
outFc = arcpy.SetParameterAsText(2, "")
env.workspace = inWorkspace
# Set local variables
fieldName1 = "bear_60"
fieldName13 = "distance"
# Execute AddField for 2 new fields
arcpy.AddField_management(inFeature, fieldName1, "DOUBLE", "", "", "", "", "NON_NULLABLE")
arcpy.AddField_management(inFeature, fieldName13, "DOUBLE", "", "", "", "", "NON_NULLABLE")
# Calculate Field bear_60
inTable = inFeature
fieldname = fieldName1
expression = "getCalc(!aspect!)"
codeblock = """def getCalc(aspect):
if aspect > 300:
bear_60 = (aspect + 60) - 360
else:
bear_60 = aspect + 60
return bear_60"""
# Execute CalculateField
arcpy.CalculateField_management(inTable, fieldname, expression, "PYTHON_9.3", codeblock)
# Calculate Field distance
inTable = inFeature
fieldname = fieldName13
expression = "getCalc(!distance!)"
codeblock = """def getCalc(distance):
return 10000"""
# Execute CalculateField
arcpy.CalculateField_management(inTable, fieldname, expression, "PYTHON_9.3", codeblock