Java arcobjects - converting labels to file GDB annotation problems

713
0
08-19-2014 11:59 AM
PeterLen
Occasional Contributor

Hello - I am using ArcGIS 10 and am using Java Arcobjects to perform some of my operations.  What I am trying to do is convert labels to geodatabase annotations within a file geodatabase.  We start out with feature classes in the file geodatabase in which we create layers that are added to our MXD document.  I need to create geodatabase annotations for the map layer feature labels.  I found an article at ArcObjects 10 Java SDK Help‌ which seems to describe how I can do this.  My code below is modeled from that article:

-------------------------------------

IConvertLabelsToAnnotation convertLabToAnno = new ConvertLabelsToAnnotation();
ITrackCancel trackCancel = new CancelTracker();
convertLabToAnno.initialize(map,
        esriAnnotationStorageType.esriDatabaseAnnotation,
        esriLabelWhichFeatures.esriAllFeatures, true, trackCancel, null);

ILayer layer = map.getLayer(layerIndex);
IGeoFeatureLayer geoFeatureLayer = (IGeoFeatureLayer)layer;
if (geoFeatureLayer != null){
    IFeatureClass featureClass = geoFeatureLayer.getFeatureClass();
    IDataset dataset = new IDatasetProxy(featureClass);
    IFeatureWorkspace featureWorkspace = new IFeatureWorkspaceProxy
                                     (dataset.getWorkspace());
    convertLabToAnno.addFeatureLayer(geoFeatureLayer, geoFeatureLayer.getName()
            + "_Annos", featureWorkspace, featureClass.getFeatureDataset(),
            featureLinked, false, false, true, true, "");

    // Do the conversion.
    convertLabToAnno.convertLabels();
}

-------------------------------------

The end result is that my file geodatabase does contain a new feature class with the extension "_Annos" for each of the origianl feature classes.  The problem is that the feature class does not have any data in it.  It is just an empty feature class which appears to contain the correct columns.  When I check each of my map's layer's properties, I see that the Label tab indicates the proper column (NAME) for the label name.  I am not sure what I am missing that is keeping the annotations from populating the annotation feature class.  I know that my feature classes have labels ( I can turn them on and off) so am not sure what I am not doing.  Does anyone have any clues??

Thanks - Peter

0 Kudos
0 Replies