public new AnnotationFeatureClassDefinition GetDefinition()
Public Shadows Function GetDefinition() As AnnotationFeatureClassDefinition
Return Value
The AnnotationFeatureClassDefinition of this dataset.
public new AnnotationFeatureClassDefinition GetDefinition()
Public Shadows Function GetDefinition() As AnnotationFeatureClassDefinition
| Exception | Description |
|---|---|
| System.InvalidOperationException | This dataset does not have a valid definition. |
| ArcGIS.Core.Data.Exceptions.GeodatabaseException | A geodatabase-related exception has occurred. |
{
Task CreatingAnAnnotationFeatureAsync(Geodatabase geodatabase) => QueuedTask.Run(() =>
{
using (AnnotationFeatureClass annotationFeatureClass = geodatabase.OpenDataset<AnnotationFeatureClass>("Annotation // feature // class // name"))
using (AnnotationFeatureClassDefinition annotationFeatureClassDefinition = annotationFeatureClass.GetDefinition())
using (RowBuffer rowBuffer = annotationFeatureClass.CreateRowBuffer())
using (AnnotationFeature annotationFeature = annotationFeatureClass.CreateRow(rowBuffer))
{
annotationFeature.SetAnnotationClassID(0);
annotationFeature.SetStatus(AnnotationStatus.Placed);
// Get the annotation labels from the label collection
IReadOnlyList<CIMLabelClass> labelClasses =
annotationFeatureClassDefinition.GetLabelClassCollection();
// Setup the symbol reference with the symbol id and the text symbol
CIMSymbolReference cimSymbolReference = new CIMSymbolReference();
cimSymbolReference.Symbol = labelClasses[0].TextSymbol.Symbol;
cimSymbolReference.SymbolName = labelClasses[0].TextSymbol.SymbolName;
// Setup the text graphic
CIMTextGraphic cimTextGraphic = new CIMTextGraphic();
cimTextGraphic.Text = "Charlotte, North Carolina";
cimTextGraphic.Shape = new MapPointBuilderEx(new Coordinate2D(-80.843, 35.234), SpatialReferences.WGS84)
.ToGeometry();
cimTextGraphic.Symbol = cimSymbolReference;
// Set the symbol reference on the graphic and store
annotationFeature.SetGraphic(cimTextGraphic);
annotationFeature.Store();
}
});
}
{
Task CreateAnnotationFeatureClassUsingExistingAnnotationFeatureClassInDatasetAsync(
Geodatabase geodatabase) => QueuedTask.Run(() =>
{
// Create a Cities annotation feature class inside Places feature dataset using existing annotation feature class
// Feature dataset name
string featureDatasetName = "Places";
// Annotation feature class name
string annotationFeatureClassName = "CitiesAnnotation";
// Create a SchemaBuilder object
SchemaBuilder schemaBuilder = new SchemaBuilder(geodatabase);
// Open existing annotation feature class name
using (AnnotationFeatureClass existingAnnotationFeatureClass = geodatabase.OpenDataset<AnnotationFeatureClass>("ExistingAnnotationFeatureClass"))
{
// Create Feature dataset description
FeatureDatasetDescription featureDatasetDescription = new FeatureDatasetDescription(featureDatasetName, existingAnnotationFeatureClass.GetDefinition().GetSpatialReference());
// Add the creation of the Places dataset to DDL task
FeatureDatasetToken featureDatasetToken = schemaBuilder.Create(featureDatasetDescription);
// Create an annotation feature class description using existing annotation feature class
AnnotationFeatureClassDescription annotationFeatureClassDescription = new AnnotationFeatureClassDescription(annotationFeatureClassName,
existingAnnotationFeatureClass.GetDefinition())
{
IsAutoCreate = true,
IsSymbolIDRequired = false,
IsUpdatedOnShapeChange = true
};
// Add the creation of the Cities annotation feature class inside Places feature dataset
schemaBuilder.Create(new FeatureDatasetDescription(featureDatasetToken),
annotationFeatureClassDescription);
// Execute the DDL
bool success = schemaBuilder.Build();
// Inspect error messages
if (!success)
{
IReadOnlyList<string> errorMessages = schemaBuilder.ErrorMessages;
//etc.
}
}
});
}
Target Platforms: Windows 11 Home, Pro, Enterprise (64 bit)