Select to view content in your preferred language

script tool geoprocessing output NOT displayed to arcmap

2235
2
02-18-2011 04:00 PM
DaveVerbyla
Occasional Contributor
Is there a simpler workaround instead of arcpy.mapping modules to get the output from geoprocessing to display to arcmap when running a script tool?  I am in arcmap with geoprocessing option checked on to add geoprocessing results to display...which it does in the Python window, but not using a script tool..
For example:
import arcpy
inFC = arcpy.GetParameterAsText(0)
arcpy.MakeFeatureLayer_management(inFC,"Test_Layer")
works, but does not return a "Test_Layer" to the data frame or table of contents.

running in the Python window, it works fine:
import arcpy
inFC = r'c:\test\Points.shp'
arcpy.MakeFeatureLayer_management(inFC,"Test_Layer")
Tags (2)
0 Kudos
2 Replies
DanPatterson_Retired
MVP Emeritus
are you running the tool from within arctoolbox?
0 Kudos
MarieHogan
Emerging Contributor
Hi, the following will work for you.

Your script will be something like this:

import arcpy
inLayer = arcpy.GetParameterAsText(0)
outLayer = arcpy.GetParameterAsText(1)
arcpy.MakeFeatureLayer_management(inLayer,outLayer)
arcpy.SetParameterAsText(1,outLayer)

Now go through the wizard for adding the script to a toolbox. When you get to the Parameters page of the wizard you need to set your output layer as an Output using the Direction property (see the attached screengrab).

Regards,

Marie Hogan
0 Kudos