AnsweredAssumed Answered

adding a list to arcpy.AddMessage

Question asked by niklas24 on Feb 7, 2012
Latest reply on Feb 7, 2012 by niklas24
I am struggling with a part of my script. I need to create an arcpy.AddMessage that says: Projected: with the list of feature classes that were projected in the loop, each separated by a comma and no trailing comma at the end

i.e. Projected: filename, filename, filename etc.

I've been at this for 3 days and know I am missing something stupid. Any help would be appreciated. Here is my code:

# Get the spatial reference of the Feature Class from folder A # Examine all Feature Classes in folder B and report if their # spatial references match the Feature Class in folder A  import arcpy arcpy.env.overwriteOutput = True  #set up the paths targetFC = arcpy.GetParameterAsText(0) folderToExamine = arcpy.GetParameterAsText(1)  #get spatial reference for the target feature class targetDescribe = arcpy.Describe(targetFC) targetSR = targetDescribe.SpatialReference targetSRName = targetSR.Name  # Get a list of my feature classes arcpy.env.workspace = folderToExamine listOfFCs = arcpy.ListFeatureClasses()  #Loop through the list of FCs for currentFC in listOfFCs:     #Read the spatial reference of the current one     currentFCDescribe = arcpy.Describe(currentFC)     currentFCSR = currentFCDescribe.SpatialReference     currentFCSRName = currentFCSR.Name          if currentFCSRName != targetSRName:         print "Spatial references don't match"     else:         print "Spatial references do match"        if currentFCSRName == targetSRName:         continue     else:        # Determine the new output feature class path and name         outCS = currentFC[:-4] +"_projected.shp"         #Reproject datasets that are different from target file         arcpy.Project_management(currentFC, outCS, targetSR)          #Create a message stating which files were projected         projFCs = outCS[:-14] +".shp"         projFCList = arcpy.ListFeatureClasses(projFCs)         x = ", ".join(projFCList) + ", "         arcpy.AddMessage("Projected " + str(x))