Original User: luke.kaimHi Everyone,Let me start by thanking you in advance.The problem I am encountering is that line features do not close on themselves. I need to go through every line feature, select the first point X,Y coordinate store that point X,Y coordinate and add it to the end of the line Array. This will then close the line feature which is the desired goal of the code. I am trying to do this using the insert and search cursor. The code is not working though. My first issue is that the code will not create a feature class and then output it to the correct directory. I am not sure if I have the correct logic as well. Would you be able to look at the below code? I can also add a feature class which is a selection of the data.# Luke Kaim 10/26/12 # The goal of this code is to close all line features such that the first coordinate and the last coordinate of a feature match. # Import arcpy module import arcpy, sys, os, re import arcpy from arcpy import env env.overwriteOutput = True env.workspace = "C:\\Users\\Luke Kaim\\Documents\\University of Maine\\Fall_2012\\Volunteer Geographic Information\\Data\\test" # Get the output feature class infile = r"C:\Users\Luke Kaim\Documents\University of Maine\Fall_2012\Volunteer Geographic Information\Data\test\selectedlines.gdb\line" outfile = (r"C:\Users\Luke Kaim\Documents\University of Maine\Fall_2012\Volunteer Geographic Information\Data\test\selectedlines.gdb\testline", 'w') # Identify the geometry field desc = arcpy.Describe(infile) shapefieldname = desc.ShapeFieldName OIDFieldName = desc.OIDFieldName try: # Create the output feature class # #arcpy.CreateFeatureclass(path,name,"POLYLINE", infile) arcpy.CreateFeatureclass_management(os.path.dirname(outfile), os.path.basename(outfile), "Polyline", infile) rows = arcpy.SearchCursor(infile) cur = arcpy.InsertCursor(outfile) # Create an array and point object needed to create features lineArray = arcpy.Array() pnt = arcpy.Point() # Iterate through the rows in the cursor for row in rows: # Create the geometry object feat = row.getValue(shapefieldname) # Print the current multipoint's ID print "Feature %i:" % row.getValue(desc.OIDFieldName) partnum = 0 # Step through each part of the feature for part in feat: # Print the part number print "Part %i:" % partnum # Step through each vertex in the feature for pnt in feat.getPart(partnum): if pnt: Print x,y coordinates of current point print pnt.X, pnt.Y if partnum==1: firstpnt.X=pnt.X firstpnt.Y=pnt.Y lineArray.add(pnt) feat = cur.newRow() # Set the geometry of the new feature to the array of points # lineArray.add(firstpnt) feat.shape = lineArray # Insert the feature cur.insertRow(feat) lineArray.removeAll() partnum += 1 del cur, rows except Exception as e: print e.message