AnsweredAssumed Answered

Cannot get field calculator expression correct

Question asked by wtgeographer on Jun 12, 2014
Latest reply on Jun 12, 2014 by rfairhur24
I am looking to calculate "ID" field w/ the last character of input fc along with OBJECTID value. Instead I receive the value of "1" for each record of "ID" in the output?
    fclist = arcpy.ListFeatureClasses("Simplified_*","Line")      for fc in fclist:          Name = "Split_" + str(fc[-1])          arcpy.CreateFeatureclass_management(inGDB,Name,"POLYLINE","#","DISABLED","DISABLED",2275)         arcpy.AddField_management(Name,"ID","TEXT","#","#","#","#","NULLABLE","NON_REQUIRED","#")            #Insert cursor to insert row into feature class table         iCursor = arcpy.da.InsertCursor(Name, ["ID","SHAPE@"])          with arcpy.da.SearchCursor(fc,["OID@", "SHAPE@"]) as sCursor:             for row in sCursor:                 ID = row[0]                 for part in row[1]:                     partnum = 0                     prevX = None                     prevY = None                     for pnt in part:                         if pnt:                             # Print x,y coordinates of current point                             #                             print("{0}, {1}".format(pnt.X, pnt.Y))                             if prevX:                                 array = arcpy.Array([arcpy.Point(prevX, prevY),                                                      arcpy.Point(pnt.X, pnt.Y)])                                 polyline = arcpy.Polyline(array)                                 iCursor.insertRow([ID,polyline])                             prevX = pnt.X                             prevY = pnt.Y                         else:                             # If pnt is None, this represents an interior ring                             #                             print("Interior Ring:")                     partnum += 1          Expression = fc[-1] + "!OBJECTID!"         arcpy.CalculateField_management(Name,"ID", Expression ,"PYTHON")          del iCursor