AnsweredAssumed Answered

Dynemic script attached to a tool

Question asked by IlanGoichman on Jul 8, 2012
Latest reply on Jul 8, 2012 by IlanGoichman
Hello everyone,

My name is Ilan and im new to Python. This is actually the 1st script im trying to write.
The script has 3 Parameters which are:

1) the input shapefile.
2) the folder where all the data will be saved.
3) a radius for the buffer the script will make.

those 3 parameters will always change depending on the user of the tool and the input so all 3 are "GetParameterasText()"

The tool will then create a buffer and save it to the folder the user specified.

then i need to use the select by location tool to select polygons and polylines from 16 other shapefiles that intersects with the buffer.

the problam is that i dont know how to refer to the buffer shapefile in the select layer by location tool, since there is no parmanent path - the path is different depending on the
the user - what he entered at the begining.

this is the script:
# Name: Mapping Script
# Purpose: Creatng Mapping data for Plans
# Author: IlanGoichman
# Created: 04/07/2012
# Copyright: (c) IlanGoichman 2012
# Licence: <your licence>

# Import the arcgisscripting module.
import arcpy
import os
import sys
import string

# Setting the Variabls.

# Input Shapefile or GDB Feature class (must be Polygon).
Input_Kav_Kachol = arcpy.GetParameterAsText(0)

# Output Location (the folder where the resualt will be saved, can be GDB or Dataset inside GDB).
Workspace = arcpy.GetParameterAsText(1)

# Setting the Buffer distance around the Input Shapefile or Feature class.
Distance = arcpy.GetParameterAsText(2)

arcpy.env.workspace = Workspace

Output_Feature_Class = "Buffer"

# Creating the Buffer.
arcpy.Buffer_analysis(Input_Kav_Kachol, Output_Feature_Class, Distance, "", "", "all")

# Setting Local variables for the Make Feature Layer tool:
topo_line_shp = "W:\\Av_data\\cover_new\\mamag_mapi\\topo_line.shp"
Output_Layer = "topo_line_Layer"

# Making temporary Feature Layers from the mamag_mapi shapefils.
# the Select by Location tool requires Feature Layers,
# it cannot work with Shapefiles or Feature Classes.
arcpy.MakeFeatureLayer_management(topo_line_shp, Output_Layer)

# Selecting all the Lins from topo_line Shapefile
# that intersects with the buffer.
arcpy.SelectLayerByLocation_management(Output_Layer, "INTERSECT", Workspace("Buffer"), "", "NEW_SELECTION")

everthing works good until the select layer by location - i get an error massage:" 'unicode' object is nor callable". which means that i didnt refer to the Buffer shapefile right.

can any1 help me please fix this code? i would realy apriciate it since iv been trying to solve this puzzle for 2 days now. :-)