Ellipse Example
This example demonstrates creating ellipses with layer-based colors. It shows how to define an ellipse using its center point and major/minor radii.
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 ellipseLayer = new Layer { Name = "TestLayer_Ellipse", ColorARGB = AciColors.Teal };
session.AddLayer(ellipseLayer);
// Ellipse using layer color
var ellipse = new Ellipse(
center: new Vector3(0, 300, 0),
radiusX: 30f,
radiusY: 15f)
{
LayerName = ellipseLayer.Name
};
session.AddElement(ellipse);
// 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
- Ellipses are defined by their center point and two radii (
RadiusX
andRadiusY
). - By default, the ellipse lies in the XY plane with its major and minor axes aligned to the X and Y axes.
- The ellipse's color is inherited from its assigned layer.