I want to unify my gdb's, and later the layers in the mxd. I ran the following script successfully, but some of my layers are not the same as the template ones. Annotation Feature classes are not created. Why doesn't this tool create Annotation Feature Classes?

import arcpy, os, sys
#list of my desired FCs in a gdb
fcList = ['FC1', 'FC2', 'FC3']
gdb = "D:\\scripttest\\fillup\\test.gdb"
spatial_reference = arcpy.Describe("D:\\scripttest\\fillup\\test.gdb\\FC").spatialReference
has_m = "DISABLED"
has_z = "DISABLED"
workspace = "D:\\scripttest\\fillup"

for fcName in fcList:
    arcpy.env.workspace = gdb
    if not arcpy.Exists(fcName):
    #Searching for a template feature class in a folder to copy it's structure and appending it to fc[]
        fc = []
        while len(fc)<1:
            for dirpath, dirnames, filenames in arcpy.da.Walk(workspace, datatype="FeatureClass"):
                for fname in filenames:
                    if fname == fcName:
                        fc.append(os.path.join(dirpath, fcName))
        print fcName + " creating"
        template = fc[0]
        print ("temp: "+ template)
        #getting the geometry_type from the template
        desc = arcpy.Describe(template)
        geometry_type = desc.shapeType
        arcpy.CreateFeatureclass_management(gdb, fcName, geometry_type, template, has_m, has_z, spatial_reference)
        print (fcName + " created")
        del fc[:]
  • Have a look at this Q&A? – Hornbydd Mar 4 at 14:59

From the tool help for Feature Class to Feature Class, the geometry type of the output featureclass to be created is listed with the following options:

POINT —Point

MULTIPATCH —Multipatch

MULTIPOINT —Multipoint

POLYGON —Polygon

POLYLINE —Polyline

Despite the help not specifically mentioning annotation featureclasses, I'd suspect based on the above list, these are the only types you could create.

You may need to enhance the code to identify Annotation Featureclasses and make use of another tool, like Append Annotation Feature Class

| improve this answer | |
  • ArcObject's 'IAnnotateLayerPropertiesCollection' Interface could help me only. But I have bad memories with vb.net, so i rather solve my problem with creating a template geodatabase by copying the missing feature classes, and with arcpy.DeleteFeatures_management() , i delete every row, so i can copy these fcs to every gdb. – gregi1991 Mar 5 at 15:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.