toolbox script to add shapefile doesn't work, same script in python window works fine

Discussion created by jgcox on Mar 1, 2011
Latest reply on Mar 1, 2011 by jgcox

  as practice, I'm trying to build a tool to let someone mouse-navigate to a shapefile and add it to their map. The script seems fairly simple, but I can't get it to work.

code (in a tool):

  This code runs fine, but nothing shows up on the map. I know it's creating something, because if I run it again, then it complains about "NewLayer" already existing. The same code (modified for a hardcoded filepath instead of GetParameterAsText, obviously), works fine when I run it in the ArcMap python window, and displays the new data on the map.

  Why won't the data display when I run the script from a tool?

Many thanks.