2 Replies Latest reply on Feb 9, 2011 10:31 AM by jvickrey79

    How to delete all featuresclasses in a FeatureDataset using ArcPy??

    jvickrey79
      Does anyone have any sample code that will delete all featuresclasses in a featuredataset using arcpy?  Many thanks for any help.

      Regards,
        • Re: How to delete all featuresclasses in a FeatureDataset using ArcPy??
          bposthumus
          1. A feature dataset is also a workspace, so set your feature dataset as the environment workspace.
          2. Iterate through each feature class in the workspace and delete it.

          I don't have ArcGIS 10.0 but in 9.3 it looks like this:

          import arcgisscripting
          gp = arcgisscripting.create(9.3)
          gp.workspace = r"C:\workspace\fileGeodatabase.gdb\featureDataset"
          for objFeatureClass in gp.listfeatureclasses():
              gp.delete(objFeatureClass)
          


          Try this in 10:

          import arcpy
          arcpy.env.workspace = r"C:\Temp\fileGeodatabase.gdb\featureDataset"
          for objFeatureClass in arcpy.ListFeatureClasses():
              arcpy.Delete_management(objFeatureClass)
          
          • Re: How to delete all featuresclasses in a FeatureDataset using ArcPy??
            jvickrey79
            1. A feature dataset is also a workspace, so set your feature dataset as the environment workspace.
            2. Iterate through each feature class in the workspace and delete it.

            I don't have ArcGIS 10.0 but in 9.3 it looks like this:

            import arcgisscripting
            gp = arcgisscripting.create(9.3)
            gp.workspace = r"C:\workspace\fileGeodatabase.gdb\featureDataset"
            for objFeatureClass in gp.listfeatureclasses():
                gp.delete(objFeatureClass)
            


            Try this in 10:

            import arcpy
            arcpy.env.workspace = r"C:\Temp\fileGeodatabase.gdb\featureDataset"
            for objFeatureClass in arcpy.ListFeatureClasses():
                arcpy.Delete_management(objFeatureClass)
            


            many thanks Brad