Diametric Dimension Example
This example demonstrates creating diametric dimensions with layer-based colors. It shows how to define a diametric dimension for a circle or arc.
using CadSDK;
using CadSDK.Elements;
using CadSDK.Enums;
using CadSDK.Geometry;
// 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.DarkestWine };
var dimLayer = new Layer { Name = "TestLayer_Dimensions", ColorARGB = AciColors.DarkYellow };
session.AddLayer(geoLayer);
session.AddLayer(dimLayer);
// Circle and dimension using layer colors
var circle1 = new Circle()
{
Center = new Vector3(150, 150, 0),
Radius = 25f,
LayerName = geoLayer.Name
};
session.AddElement(circle1);
var diametricDim1 = new DiametricDim(
referenceElementGuid: circle1.Guid,
dimLinePos: circle1.Center,
textHeight: 3f)
{
LayerName = dimLayer.Name
};
session.AddElement(diametricDim1);
// 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
- Diametric dimensions measure the diameter of a
Circle
element. - They require the GUID of the referenced circle (
ReferenceElementGuid
) and a point to define the dimension line location (DimLinePos
). - The
TextHeight
property controls the size of the dimension text. - The dimension's color is inherited from its assigned layer.