Try not specifying any subfields. I've had luck with this in the past by creating an inset cursor, calling newrow on the insert cursor, setting a value on the newrow, then inserting the newrow.
Well, I discovered a little more.
I tried what I believe to be Robert Krisher's suggestion, which is to use the standard cursor and not the data access cursor.
So, I used this code instead:
edit = arcpy.da.Editor(workspace) edit.startEditing(False, True) edit.startOperation() icur= arcpy.InsertCursor(switch) row = icur.newRow() row.setValue("Comments", "Test Comment") icur.insertRow(row) edit.stopOperation() edit.stopEditing(True)
This did fail with the same message:
RuntimeError: Field is not editable.
BUT, it also threw a more detailed error than the data access cursor did, which was:
The feature object does not have a valid shape.
So, obviously this means it needs geometry in order to be inserted (if a geometry field exists). This must be a more strict requirement by ArcFM? Because my first script worked fine in the pure ESRI world. This obviously isn't an issue, I just wish the first script threw the same error as this one.
I changed back to the data access cursor and added the Shape field and it inserted correctly.
edit = arcpy.da.Editor(workspace) edit.startEditing(False, True) edit.startOperation() icur = arcpy.da.InsertCursor(switch, ("SHAPE@", "Comments")) icur.insertRow([(5555, 5555), "Test Comment"]) edit.stopOperation() edit.stopEditing(True)
I'm suprised that you can do this with the vanilla ESRI features. I'm pretty sure that at 10.2.1 I can't create a network feature with null geometry, but I would have thought they were enforcing this since 10.x (if not 9.x!). Either way, you shouldn't be able to create a network feature with null geometry, ArcFM just has the courtesy to throw exceptions when you try and do this =)
Yeah, it totally makes sense that a feature participating in a geometric network should require geometry. It just caused a bit of confusion when it worked in one situation, but not the other. Anyway, what the above told me is that there was a different issue with my conversion script because I was inserting geometry as well as the other field values. It ended up being the Enabled field. I was defaulting to a value of 1 for True, but it didn't like that for some reason. I just removed that field from the cursor and everything worked fine.