Line Example

This example demonstrates creating lines with layer-based colors. It shows how to set up layers, create lines with styling inherited from their layer, and add them to a drawing session.

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 lineLayer = new Layer { Name = "TestLayer_Line", ColorARGB = AciColors.Blue };
session.AddLayer(lineLayer);

// Line using layer color
var line = new Line(
    startPoint: new Vector3(0, 0, 0),
    endPoint: new Vector3(100, 100, 50))
{
    LayerName = lineLayer.Name
};
session.AddElement(line);

// 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

  • The line is assigned to a specific layer for organization.
  • Lines can be positioned in 3D space using Vector3 coordinates.
  • The line's color is inherited from its assigned layer.