def Migrate_GasLamp_DA(): sSourceClass = sSourceGDB + "/gaslight" sTargetClass = "GasLamp" SourceFieldList = ["SHAPE@", "PLACEMENT_CODE"] TargetFieldList = ["SHAPE@", "ENABLED", "CREATIONUSER", \ "DATECREATED", "DATEMODIFIED", "LASTUSER"] dtCreate = datetime.now().replace(hour=0, minute=0, second=0, microsecond=0) edit = da.Editor(sTargetGDB) edit.startEditing(False, False) edit.startOperation() c = da.InsertCursor(sTargetClass, TargetFieldList) iTotal = 0 i = 0 with da.SearchCursor(sSourceClass, SourceFieldList) as cursor: for row in cursor: iTotal += 1 i += 1 if i == 1000: edit.stopOperation() edit.startOperation() i = 0 geom = row[0] sPC = row[1] tok = UserDateFromPC(sPC) sUser = tok[0] dtPC = tok[1] newrow = [geom, 1, "Data Migration", dtCreate, \ dtPC, sUser] c.insertRow(newrow) del c edit.stopOperation() edit.stopEditing(True) return iTotal
def Migrate_GasLamp_AO(): GetESRIModule("esriGeoDatabase.olb") GetESRIModule("esriDataSourcesGDB.olb") import comtypes.gen.esriGeoDatabase as esriGeoDatabase import comtypes.gen.esriDataSourcesGDB as esriDataSourcesGDB pWSF = NewObj(esriDataSourcesGDB.FileGDBWorkspaceFactory, \ esriGeoDatabase.IWorkspaceFactory) pSourceWS = pWSF.OpenFromFile(sSourceGDB, 0) pSourceFWS = CType(pSourceWS, esriGeoDatabase.IFeatureWorkspace) pTargetWS = pWSF.OpenFromFile(sTargetGDB, 0) pTargetFWS = CType(pTargetWS, esriGeoDatabase.IFeatureWorkspace) pSourceFC = pSourceFWS.OpenFeatureClass("gaslight") pTargetFC = pTargetFWS.OpenFeatureClass("GasLamp") iPC = pSourceFC.FindField("PLACEMENT_CODE") iEn = pTargetFC.FindField("ENABLED") iCU = pTargetFC.FindField("CREATIONUSER") iDC = pTargetFC.FindField("DATECREATED") iDM = pTargetFC.FindField("DATEMODIFIED") iLU = pTargetFC.FindField("LASTUSER") dtCreate = datetime.now().replace(hour=0, minute=0, second=0, microsecond=0) pFCursor = pSourceFC.Search(None, True) iTotal = 0 i = 0 pEditWS = CType(pTargetWS, esriGeoDatabase.IWorkspaceEdit) pEditWS.StartEditing(False) pEditWS.StartEditOperation() while True: pSourceFeat = pFCursor.NextFeature() if not pSourceFeat: break iTotal += 1 i += 1 if i == 1000: pEditWS.StopEditOperation() pEditWS.StartEditOperation() i = 0 sPC = pSourceFeat.Value(iPC) tok = UserDateFromPC(sPC) sUser = tok[0] dtPC = tok[1] pTargetFeat = pTargetFC.CreateFeature() pTargetFeat.Shape = pSourceFeat.Shape pTargetFeat.Value[iEn] = 1 pTargetFeat.Value[iCU] = "Data Migration" pTargetFeat.Value[iDC] = dtCreate pTargetFeat.Value[iDM] = dtPC pTargetFeat.Value[iLU] = sUser pTargetFeat.Store() pEditWS.StopEditOperation() pEditWS.StopEditing(True) return iTotal
Hi
I know its a long time ago now but I was wondering if you managed to find a solution to this. I am trying to use a insertCursor (da) to add features to a feature class that participates in geometric network and are getting this error:
error return without exception set
If I remove the Geometric Network the code works fine. I cant remove the geometric network form the Production database.
Is it possible to use the data access insertcursor to insert records into a featureclass that participates in a geometric network??
cheers
Callum
It's in the system as bug NIM-102778 (currently unresolved). Esri gives the following workaround:
The Append tool works fine for features participating in a geometric network.
1. Fill an empty feature class outside the geometric network with records using an insert cursor.
2. Use the Append tool to add the records to the feature class in the geometric network.
EDIT moved to live thread