Select to view content in your preferred language

pass the field name as parameter to the next tool

669
2
09-14-2010 09:51 AM
by Anonymous User
Not applicable
Original User: maxh718

I am creating a tool using Python, the output of the tool is a feature class.

then I want to use the field name as the value of the dropdown list of the field selection to select a field as the the buffer size, but the problem is I can not see the field names.

Did I miss something?



def main():
    inFC=arcpy.GetParameterAsText(0)
    outFC=arcpy.GetParameterAsText(1)
#    outFC=createUniqueOutputName(inFC)
    distance=arcpy.GetParameterAsText(2)
    arcpy.AddMessage("split %s into %s by %s"%(inFC,outFC,distance))
    #arcpy.AddMessage("%s--- %s "%(env.workspace,env.scratchWorkspace))
    if arcpy.Exists(outFC):
        print "%s is deleted"%outFC
        arcpy.Delete_management(outFC)
     ## create outFC
    out_path = os.path.dirname(outFC)
    arcpy.AddMessage(out_path)
    out_name = os.path.basename(outFC)
    arcpy.AddMessage(out_name)
    geometry_type = "POLYLINE"
    template=inFC
    arcpy.CreateFeatureclass_management(out_path, out_name, geometry_type,template)
    arcpy.AddMessage("before splitting")
    splitLineByDistance(inFC,outFC,200)

if __name__ == '__main__':
    main()
0 Kudos
2 Replies
by Anonymous User
Not applicable
Original User: curtvprice

This is controlled in the parameter tab when you add the script tool to the toolbox (not in ModelBuilder). Hope this helps.
0 Kudos
curtvprice
MVP Esteemed Contributor
If you right click on your script tool .. create variable .. field argument. This will create a model element for that script tool argument.

then in your model you can connect that model element to the next tool (assuming it's a field object).

An annoying issue is when the input is a string (say the name for Add Field) you sometimes need to convert the type - this can be done with the Calculate Value tool which can be set to return an object of specified type. (ie a Field object)
0 Kudos