I'm trying to populate a Geodatabase with roundabout 60 Datasets with a new Featureclass for each Dataset. To do this, i wrote a python-standalone-script that loops through these datasets and creates a new Featureclass with the "CreateFeatureclass_management"-Tool and do some stuff with this Featureclass afterwards.
This works for the first Dataset, but when my script reaches this command for the next Dataset, the processing of my script is interrupted. I don't get a Traceback, instead an Windows-Error-message pops up, saying smth. like "pythonw.exe registered an error and has to be cancelled" (Maybe the wording is a bit different, since i translated it from german).
So, this Problem always occures for the second Featureclass that should be generated. If i extract the first Dataset with the correct generated Featureclass from my Geodatabase and start the script again, again the Featureclass will be added to the first Dataset (the former second), but not to the following. So it's not a question of my Data. I also doubt if it's something in my scriptcode itself, since i wrote a very simple Testscript afterwards, that is able to create 4 Featureclasses in ONE Dataset, but isn't able to create Featureclasses in more than one Dataset.
I really dont see any reason for my script to not create these Featureclasses. If you demand it, i can definitely post some scriptcode. Anyway, i fear that it has smth to do with my cache or so.
Here is the code of my testsript: ( It actually breaks at the first AddField_management instead of my CreateFeatureclass_management, after I changed it a bit)
import arcpy, os Geodatabase = r"D:\GIS\STK\124_NDS\STK_124_NDS.gdb" arcpy.env.overwriteOutput = True def CreateFeatureclasses(workspace): arcpy.env.workspace = Geodatabase listDatasets = arcpy.ListDatasets("", "Feature") for dataset in listDatasets: datasetPath = workspace + os.sep + dataset arcpy.env.workspace = datasetPath print "Dataset: " + dataset out_name = "BF_Stao_Bodenprofil_P_" + dataset[9:] Bohrpunkt_fc = arcpy.CreateFeatureclass_management (datasetPath, out_name, "POINT") fcList = arcpy.ListFeatureClasses() for fc in fcList: if fc[:10] == "Bohrpunkte": Punkteliste =  zeilen = arcpy.SearchCursor(fc) for zeile in zeilen: Bohrkreisgeometrie = zeile.getValue("Shape") Bohrpunkt = Bohrkreisgeometrie.trueCentroid Punkteliste.append(Bohrpunkt) del zeilen rows = arcpy.InsertCursor(Bohrpunkt_fc) for Punkt in Punkteliste: feature = rows.newRow() feature.shape = Punkt rows.insertRow(feature) del rows, Punkteliste print "Die Punkt-Geometrien fuer die Featureclass 'BF_Stao_Bodenprofil_P' wurden erstellt." Liegenschaftsnummer = dataset[1:8] arcpy.AddField_management (Bohrpunkt_fc, "Lgs_Nummer", "TEXT", "", "", 7) arcpy.AddField_management (Bohrpunkt_fc, "Profil_ID", "TEXT", "", "", 12) arcpy.AddField_management (Bohrpunkt_fc, "Profil_Nr_alt", "TEXT", "", "", 4) arcpy.AddField_management (Bohrpunkt_fc, "Profiltyp", "SHORT", 1) arcpy.AddField_management (Bohrpunkt_fc, "Standortseinheit", "TEXT") del Bohrpunkt_fc del listDatasets CreateFeatureclasses(Geodatabase)
I had some tries to solve my Problem:
First, I made a Batch-Script-tool out of my standalone Script. As before, the script is processed for my first Dataset, but not for the following. Now I get a "serious application error" and the script is interrupted.
So, my second try was to discard the idea of processing my Data in all Dataset by looping through them/ using a Batch and instead using a simple script-tool, where i have to set the workspace individually for every dataset. After using the script for the first dataset, I open it again, set the workspace to the second an start it again, and -what a surprise - the same error occurs again. I first have to close ArcCatalog before i can start the script again....
Can this indicate, that there is some lock remaining, after the script is terminated? I delete every single reference before the script ends and delete temporary featureclasses.
Any advice? Or has someone else experienced this before?