
public sealed class AnnotationFeatureClassDescription : FeatureClassDescription
Public NotInheritable Class AnnotationFeatureClassDescription Inherits FeatureClassDescription
public void CreateAnnotationFeatureClassUsingExistingAnnotationFeatureClassInDataset(Geodatabase geodatabase) { // 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. } } }
public void CreateDimensionFeatureClass(Geodatabase geodatabase) { // Dimension feature class name string dimensionFeatureClassName = "LineInfo"; // Create user defined attribute fields for dimension feature class FieldDescription nameFieldDescription = new FieldDescription("Name", FieldType.String); FieldDescription distanceFieldDescription = new FieldDescription("DistanceMeasure", FieldType.Double); FieldDescription measurementDateFieldDescription = new FieldDescription("MeasurementDate", FieldType.Date); // Create a list of all field descriptions List<FieldDescription> fieldDescriptions = new List<FieldDescription> { nameFieldDescription, distanceFieldDescription, measurementDateFieldDescription }; // Create a ShapeDescription object ShapeDescription shapeDescription = new ShapeDescription(GeometryType.Polygon, SpatialReferences.WGS84); // Create a SchemaBuilder object SchemaBuilder schemaBuilder = new SchemaBuilder(geodatabase); // Create DimensionFeatureClassDescription object DimensionFeatureClassDescription dimensionFeatureClassDescription = new DimensionFeatureClassDescription(dimensionFeatureClassName, fieldDescriptions, shapeDescription, GetCIMDimensionStyles()); // Token DimensionFeatureClassToken dimensionFeatureClassToken = schemaBuilder.Create(dimensionFeatureClassDescription); // Execute the DDL bool success = schemaBuilder.Build(); // Inspect error messages if (!success) { IReadOnlyList<string> errorMessages = schemaBuilder.ErrorMessages; //etc. } } private List<CIMDimensionStyle> GetCIMDimensionStyles() { CIMColor color = CIMColor.CreateRGBColor(10, 20, 30); CIMPointSymbol beginMarkerSymbol = GetMarkerSymbol(color); CIMPointSymbol endMarkerSymbol = GetMarkerSymbol(color); CIMLineSymbol dimensionLineSymbol = GetLineSymbol(color, 0.5); CIMLineSymbol extensionLineSymbol = GetLineSymbol(color, 0.5); CIMTextSymbol textSymbol = GetDefaultTextSymbol(10); textSymbol.Symbol = GetPolygonSymbol(color, color, 0); textSymbol.HorizontalAlignment = HorizontalAlignment.Center; CIMDimensionStyle cimDimensionStyle = new CIMDimensionStyle() { Name = "Style 1", ID = 0, Align = true, DisplayUnits = null, DisplayPrecision = 0, BeginMarkerSymbol = beginMarkerSymbol, EndMarkerSymbol = endMarkerSymbol, MarkerOption = DimensionPartOptions.Both, MarkerFit = DimensionMarkerFit.Text, DimensionLineSymbol = dimensionLineSymbol, DimensionLineOption = DimensionPartOptions.Both, DrawLineOnFit = false, ExtendLineOnFit = true, BaselineHeight = 0.0, ExtensionLineSymbol = extensionLineSymbol, ExtensionLineOption = DimensionPartOptions.Both, ExtensionLineOvershot = 0.0, ExtensionLineOffset = 0.0, Expression = "", ExpressionParserName = "Arcade", TextSymbol = textSymbol, TextOption = DimensionTextOption.Only, TextFit = DimensionTextFit.MoveBegin, }; List<CIMDimensionStyle> cimDimensionStyles = [cimDimensionStyle]; return cimDimensionStyles; } private CIMFill DefaultFill(CIMColor color) { return new CIMSolidFill() { Enable = true, Name = "Fill_" + Guid.NewGuid().ToString(), ColorLocked = false, Color = color }; } private CIMStroke DefaultStroke(CIMColor color, double width = 1) { return new CIMSolidStroke() { Color = color, Name = "Stroke_" + Guid.NewGuid().ToString(), CapStyle = LineCapStyle.Round, JoinStyle = LineJoinStyle.Round, CloseCaps3D = false, LineStyle3D = Simple3DLineStyle.Strip, MiterLimit = 4, Width = width, ColorLocked = false, Enable = true, }; } private CIMPolygonSymbol GetPolygonSymbol(CIMColor fillColor, CIMColor outlineColor, double outlineWidth) { if ((outlineColor == null) || (outlineWidth <= 0)) return new CIMPolygonSymbol() { SymbolLayers = new CIMSymbolLayer[1] { DefaultFill(fillColor) } }; return new CIMPolygonSymbol() { SymbolLayers = new CIMSymbolLayer[2] { DefaultStroke(outlineColor, outlineWidth), DefaultFill(fillColor) } }; } private CIMLineSymbol GetLineSymbol(CIMColor color, double width) { var stroke = DefaultStroke(color, width); return new CIMLineSymbol() { SymbolLayers = new CIMSymbolLayer[1] { stroke } }; } private Polygon CreateArrowGeometry() { double x = 2.39; double y = 1.20; double xMod = 0.3; var pt1 = new Coordinate2D() { X = -x + xMod, Y = -y }; var pt2 = new Coordinate2D() { X = x + xMod, Y = 0 }; var pt3 = new Coordinate2D() { X = -x + xMod, Y = y }; var coords = new List<Coordinate2D>() { pt1, pt2, pt3 }; var polygon = PolygonBuilderEx.CreatePolygon(coords); return polygon; } private CIMPointSymbol GetMarkerSymbol(CIMColor color) { CIMMarkerGraphic graphic = new CIMMarkerGraphic() { Geometry = CreateArrowGeometry(), Symbol = new CIMPolygonSymbol() { SymbolLayers = new CIMSymbolLayer[1] { new CIMSolidFill() { Enable = true, Color = color, } }, UseRealWorldSymbolSizes = false } }; CIMSymbolLayer symbolLayer = new CIMVectorMarker() { Enable = true, Size = 12, Frame = new EnvelopeBuilderEx() { XMin = -5, YMin = -3, XMax = 5, YMax = 3 }.ToGeometry() as Envelope, MarkerGraphics = new CIMMarkerGraphic[1] { graphic }, ScaleSymbolsProportionally = true, RespectFrame = true }; return new CIMPointSymbol() { SymbolLayers = new CIMSymbolLayer[1] { symbolLayer }, HaloSize = 1, ScaleX = 1, AngleAlignment = AngleAlignment.Map, }; } private CIMTextSymbol GetDefaultTextSymbol(double height) { return new CIMTextSymbol() { DrawGlyphsAsGeometry = false, DrawSoftHyphen = false, ExtrapolateBaselines = true, FlipAngle = 0.0, IndentAfter = 0.0, IndentBefore = 0.0, IndentFirstLine = 0.0, Kerning = true, LetterSpacing = 0.0, LetterWidth = 100.0, Ligatures = true, LineGap = 0.0, LineGapType = LineGapType.ExtraLeading, Underline = false, Strikethrough = false, OffsetX = 0.0, OffsetY = 0.0, FontFamilyName = "Tahoma", FontStyleName = "Regular", WordSpacing = 100.0, Height = height }; }
System.Object
ArcGIS.Core.Data.DDL.Description
ArcGIS.Core.Data.DDL.TableDescription
ArcGIS.Core.Data.DDL.FeatureClassDescription
ArcGIS.Core.Data.DDL.AnnotationFeatureClassDescription
Target Platforms: Windows 11, Windows 10