AnsweredAssumed Answered

Problem with clip script wich loops throught attributes of clipping layer

Question asked by JB1234510 on Jul 20, 2016
Latest reply on Jul 21, 2016 by rastrauch

Error message in script which worked correctly days before? Any ideas why?

 

line 16, in <module>

    quercy = field + "=" + "'" + Loop1 + "'"

TypeError: cannot concatenate 'str' and 'int' objects

 

import arcpy
import os
input = arcpy.GetParameterAsText(0)
clipfeature = arcpy.GetParameterAsText(1)
output = arcpy.GetParameterAsText(2)
clipfeature_Layer = "clipfeature_Layer"
arcpy.env.workspace = output
arcpy.env.overwriteOutput = True
field = "BFN_NR"
inputSp = input.split(";")
arcpy.MakeFeatureLayer_management(clipfeature, clipfeature_Layer, "", "", "")
cursor = arcpy.SearchCursor(clipfeature)
for row in cursor:
    arcpy.AddMessage(row.getValue(field))
    Loop1 = row.getValue(field)
    quercy = field + "=" + "'" + Loop1 + "'"

    arcpy.SelectLayerByAttribute_management (clipfeature_Layer, "NEW_SELECTION", quercy)
    Sel_shape = "Sel_" + Loop1 + ".shp"
    arcpy.CopyFeatures_management(clipfeature_Layer, Sel_shape)
    for i in inputSp:

        arcpy.AddMessage(i)
        arcpy.Clip_analysis(i, Sel_shape, "Clip_" + row.getValue(field) + "_" + i) 

Outcomes