Angular Dimension Example
This example demonstrates creating angular dimensions with layer-based colors. It shows how to define an angular dimension measuring the angle between two lines.
using CadSDK;
using CadSDK.Elements;
using CadSDK.Enums;
using CadSDK.Geometry;
using System.Numerics;
// Create a drawing session
var session = new DrawingSession
{
ExportFormat = ExportFormat.DWG,
CadVersion = CadVersion.Cad2018
};
// Define layers
var geoLayer = new Layer { Name = "TestLayer_Dimensions_Geometry", ColorARGB = AciColors.RosyBrown };
var dimLayer = new Layer { Name = "TestLayer_Dimensions", ColorARGB = AciColors.White };
session.AddLayer(geoLayer);
session.AddLayer(dimLayer);
// Angular dimension using layer colors
var center1 = new Vector3(50, 350, 0);
var p1 = new Vector3(100, 350, 0);
var p2 = new Vector3(70, 423, 0);
var line1 = new Line { StartPoint = center1, EndPoint = p1, LayerName = geoLayer.Name };
var line2 = new Line { StartPoint = center1, EndPoint = p2, LayerName = geoLayer.Name };
session.AddElement(line1);
session.AddElement(line2);
var angularDim1 = new AngularDim(
plane: Plane3D.WorldXY,
line1Guid: line1.Guid,
line2Guid: line2.Guid,
quadrantPoint: new Vector3(60, 360, 0),
dimLinePos: new Vector3(60, 360, 0),
textHeight: 4f)
{
LayerName = dimLayer.Name,
AngleFormat = AngleFormatType.DecimalDegrees
};
session.AddElement(angularDim1);
// Export the drawing
// You can signup and get your free API key
string apiKey = "your-api-key"; // Get your free API key from the dashboard
string outputPath = "drawing.dwg";
await session.ExportAndSaveAsync(apiKey, outputPath);
# Coming soon...
Key Points
- Angular dimensions measure the angle between two existing
Line
elements. - They require the GUIDs of the two lines (
Line1Guid
,Line2Guid
) and points to define the dimension arc (QuadrantPoint
,DimLinePos
). - The
AngleFormat
property controls how the angle value is displayed (e.g., decimal degrees). - The dimension's color is inherited from its assigned layer.