I have 150+ feature classes in SDE for which I need to create an empty feature class in a file geodatabase. For these feature classes I need to import the attributes and the name of the feature class as in SDE. I tried to export to an XML workspace document but it is not working because of some error on the SDE and I'm not an SDE administrator, so I am unable to modify the things on the SDE.
An alternative to this that I tried was creating a script in Python for creating the feature class. I get the names of the feature class from the SDE but am unable to create them on the local SDE.
Also how can I read the geometry type for the feature class in arcpy?
Here is the code I've written:
import arcpy
arcpy.env.workspace= r"C:\Users\088927\AppData\Roaming\ESRI\Desktop10.0\ArcCatalog\ENT-QA @ sample.sde"
fcList = arcpy.ListFeatureClasses('sde."ENT-QA".*',"","")
output = "C:/Users/088927/Desktop/Schema.gdb"
for fc in fcList:
fullName = arcpy.ParseTableName(fc)
#fcTemplate = fc.
finallist = []
nameList = fullName.split(",")
databaseName=nameList[0]
ownerName = nameList[1]
fcName = nameList [2]
fcStr = str(fcName)
print fcStr
arcpy.CreateFeatureclass_management(r"C:\Users\abc\Desktop\Schema.gdb",fcstr)
Best Answer
Just use the CreateFeatureClass tool, passing the original feature class as the template argument. Grab the shape type from the Describe object of the input feature class.
Unlike the other answer, this won't copy a bunch of unnecessary records only to delete them right away.
UPDATE:
If you need to preserve domains/subtypes, then run
Select_analysis
using a generic where clause that will capture none of the records, likeOBJECTID < 0
:This is far more efficient than copying all the records and then deleting them. I've yet to find an approach that will preserve editor tracking.