if index !=len(fclist)-1: or if index ==len(fclist)-1:
for index, value in enumerate(fclist, start=1): looptime = time.asctime() print "Début de la boucle d'intersection en batch:" + looptime print value # Intersection arcpy.Intersect_analysis([IntersectBoucle,value],OutIntersectBoucle) print "#### " + str(i) + "ieme intersection(Boucle) ###########" print "L'intersection est entre : " + str(OutIntersectBoucle)+ " et " + str(value) fieldnames4 = [f.name for f in arcpy.ListFields(OutIntersectBoucle)] # Populate field isSame, Supported and Supporting arcpy.CalculateField_management(OutIntersectBoucle,"isSame","isSame( !Name!, !Name_1! )","Python_9.3",codeblock) arcpy.CalculateField_management(OutIntersectBoucle,"Supported","PeuplerZone ( !isSame!, !Name!)","Python_9.3",codeblock2) arcpy.CalculateField_management(OutIntersectBoucle,"Supporting","PeuplerZone ( !isSame!, !Name_1!)","Python_9.3",codeblock3) j += 1 if index !=len(fclist)-1: print "La dernière intersection est :" + str(OutIntersectBoucle) + " + 1" arcpy.CalculateField_management(OutIntersectBoucle,"isSame","poly_exc( !isSame!)","Python_9.3",codeblock4)
Solved! Go to Solution.
lstindex = len(fclist)
for index, value in enumerate(fclist, start=1):
if index == len(fclist)-1:
i = 1 for index, value in enumerate(fclist, start=1): looptime = time.asctime() print "Début de la boucle d'intersection en batch:" + looptime print value # Intersection #arcpy.Intersect_analysis([IntersectBoucle,fclistBoucle],OutIntersectBoucle) arcpy.Intersect_analysis([IntersectBoucle,value],OutIntersectBoucle) print "#### " + str(i) + "ieme intersection(Boucle) ###########" print "L'intersection est entre : " + str(OutIntersectBoucle)+ " et " + str(value) fieldnames4 = [f.name for f in arcpy.ListFields(OutIntersectBoucle)] # Peupler les champs isSame, Supported and Supporting # Populate field isSame, Supported and Supporting arcpy.CalculateField_management(OutIntersectBoucle,"isSame","isSame( !Name!, !Name_1! )","Python_9.3",codeblock) arcpy.CalculateField_management(OutIntersectBoucle,"Supported","PeuplerZone ( !isSame!, !Name!)","Python_9.3",codeblock2) arcpy.CalculateField_management(OutIntersectBoucle,"Supporting","PeuplerZone ( !isSame!, !Name_1!)","Python_9.3",codeblock3) j += 1 if index ==len(fclist)-1: print "La dernière intersection est :" + str(OutIntersectBoucle) + " + 1" arcpy.CalculateField_management(OutIntersectBoucle,"isSame","poly_exc( !isSame!)","Python_9.3",codeblock4) # Extraire les enregistrements qui respectent les conditions pour les zones soutenues et supportées # Extract feature that meets requirements for Supporting and Supported zones arcpy.CopyFeatures_management(OutIntersectBoucle, outIntersect) # Extract feature that doesn't meets requirements and needs to be Intersect again arcpy.MakeFeatureLayer_management(OutIntersectBoucle,IntersectBoucle,isSameQuery) arcpy.DeleteField_management(IntersectBoucle,DropField) outIntersect = mainFolder + "\\" + "Intersect" + "\\" + "Intersect" + str(j) OutIntersectBoucle = "in_memory" + "\\" + "OutIntersect" + str(j) i += 1
lstindex = len(fclist)