Basically what I want to archive: Create single lines out of one selected polyline with many vertex points. I do a cut, copy, and paste process as follows and it does the trick.
# (cut)
arcpy.SplitLine_management("FGK_t0_Line","line_tmpvar")
arcpy.DeleteFeatures_management("FGK_t0_Line")
env = EnvVar()
cmd = Commands()
# container for all lines (copy)
fl=[]
with arcpy.da.SearchCursor("line_tmpvar",["Shape@","LineType"]) as sc:
for row in sc:
fl.append(row)
# start edit session to insert (paste), because of topograpy relationship/feature dataset
cmd.clsAllSelections()
edit = arcpy.da.Editor(env.wd)
edit.startEditing(False, True)
edit.startOperation()
with arcpy.da.InsertCursor(env.wd+r"\\TopoTestSet\\FGK_t0_Line", ["Shape@","LineType"]) as ic:
for f in fl:
ic.insertRow(f)
edit.stopOperation()
edit.stopEditing(True)
However, I would like to use the with edit command instead of the lines 13, 14, 15, 19 and 20. Therefore, I was trying to use it as follows:
# (cut)
arcpy.SplitLine_management("FGK_t0_Line","line_tmpvar")
arcpy.DeleteFeatures_management("FGK_t0_Line")
env = EnvVar()
cmd = Commands()
# container for all lines (copy)
fl=[]
with arcpy.da.SearchCursor("line_tmpvar",["Shape@","LineType"]) as sc:
for row in sc:
fl.append(row)
# start edit session to insert (paste), because of topograpy relationship/feature dataset
cmd.clsAllSelections()
with arcpy.da.Editor(env.wd) as edit:
with arcpy.da.InsertCursor(env.wd+r"\\TopoTestSet\\FGK_t0_Line", ["Shape@","LineType"]) as ic:
for f in fl:
edit.startOperation()
ic.insertRow(f)
edit.stopOperation()
It always fails with the runtime error:
Runtime error
Traceback (most recent call last):
File "<string>", line 16, in <module>
AttributeError: 'Workspace Operation object' object has no attribute 'startOperation'
As you can see I have all my environment settings saved in an object called "env", which worked in the first part. So what am I doing wrong?
>>> print env.wd
C:\Data\DigitestV02.gdb