AC1009‑version DXF files have an issue with layer reading, and this also affects the colors of entities that depend on layers (ByLayer).
Layer.zip
The DXF test file contains only one layer (Name: 0), whose color is red. Inside that layer there are only two lines: one inherits the layer’s red color, and the other is green.
The test code is as follows:
static void Main(string[] args)
{
CadDocument doc;
using (DxfReader reader = new(_file, NotificationHelper.LogConsoleNotification))
{
doc = reader.Read();
}
Console.WriteLine("@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@");
foreach (var layer in doc.Layers)
{
Console.WriteLine($"Name: {layer.Name}, Color {layer.Color}");
}
Console.WriteLine("@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@");
IEnumerable<Line> lines = doc.Entities.OfType<Line>();
foreach (var line in lines)
{
var start = line.StartPoint;
var end = line.EndPoint;
Color color = line.GetActiveColor();
ReadOnlySpan<byte> b = Color.GetIndexRGB((byte)color.Index);
Console.WriteLine($"Line ID: {line.Handle}");
Console.WriteLine($"Layer: {line.Layer}");
Console.WriteLine($"StartPoint: ({start.X:F2}, {start.Y:F2}, {start.Z:F2})");
Console.WriteLine($"EndPoint: ({end.X:F2}, {end.Y:F2}, {end.Z:F2})");
Console.WriteLine($"Color: {color}");
Console.WriteLine($"Color: R={b[0]}, G={b[1]}, B={b[2]}");
Console.WriteLine($"Transparency: {line.Transparency.Value}");
Console.WriteLine("--------------------------------------");
}
}
Console output:
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
Name: unnamed0, Color Indexed Color:1
Name: 0, Color Indexed Color:7
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
Line ID: 134
Layer: LAYER:0
StartPoint: (214.60, 189.18, 0.00)
EndPoint: (372.46, 189.18, 0.00)
Color: Indexed Color:7
Color: R=255, G=255, B=255
Transparency: -1
--------------------------------------
Line ID: 135
Layer: LAYER:0
StartPoint: (214.60, 127.66, 0.00)
EndPoint: (378.09, 127.66, 0.00)
Color: Indexed Color:3
Color: R=0, G=255, B=0
Transparency: -1
--------------------------------------
AC1009‑version DXF files have an issue with layer reading, and this also affects the colors of entities that depend on layers (ByLayer).
Layer.zip
The DXF test file contains only one layer (Name: 0), whose color is red. Inside that layer there are only two lines: one inherits the layer’s red color, and the other is green.
The test code is as follows:
Console output: