def CreateBiDirectionalRoute(input_lines, _routes): try: in_geo = [i for i in arcpy.da.SearchCursor(input_lines, ['ID', 'SHAPE@', 'SPEEDLIMIT'])] incur = arcpy.da.InsertCursor(nztm_routes, ['ROUTENAME', 'ROUTENUM', 'JOINFIELD', 'SHAPE@', 'SPEEDLIMIT']) for _geo in in_geo: incur.insertRow([_geo[0], 'A', str(_geo[0])+'-'+'A', _geo[1].projectAs(arcpy.SpatialReference(###), ###), _geo[2]]) flip_features = arcpy.FlipLine_edit(input_lines) in_geo2 = [k for k in arcpy.da.SearchCursor(flip_features, ['ID', 'SHAPE@','SPEEDLIMIT'])] for _geo2 in in_geo2: incur.insertRow([_geo2[0], 'B', str(_geo2[0])+'-'+'B', _geo2[1].projectAs(arcpy.SpatialReference(###), ###), _geo2[2]]) del incur except arcpy.ExecuteError: arcpy.AddMessage(arcpy.GetMessages(2))
Hi guys,
from the above code, if I use a versioned sde featureclass as inputlines, I get the error above based on line 7. Is there a work around to be able to use versioned fcs for this function of mine?
Thanks
I'm wondering if it is the versioning that is the problem. The help Flip Line—Help | ArcGIS for Desktop mentions that is is a "tool with no outputs", which mentions
"When input data is stored in a versioned database, tools will only modify the single version of the data. To apply changes to the rest of the database, the version must be reconciled and posted."
I'm wondering if it has an issue with that. ??
And is an editor session started somewhere outside of this function.
http://desktop.arcgis.com/en/desktop/latest/analyze/arcpy-data-access/editor.htm
I actually tried loading the versioned fc on arcgis desktop and did the flip line tool (not in editing mode). It worked without any issue. So it's just weird that thru arc py implementation it fails. removing the version, function runs fine.
The flip line in ArcMap is fine. One operation.
Inside python you have 2. An insert Cursor and the flip.
I believe you will need to open a da.Editor session for this.
Like :
# start editing edit = arcpy.da.Editor(os.path.dirname(outputDataLocation)) edit.startEditing(False, False) # check these settings in the help edit.startOperation() # do stuff here edit.stopOperation() edit.stopEditing(True)