DomCR / ACadSharp

C# library to read/write cad files like dxf/dwg.
MIT License
416 stars 117 forks source link

Not able to set circle color to "ByLayer" in DWG #217

Closed nag-fdestech closed 11 months ago

nag-fdestech commented 11 months ago

I'm trying to generate a DWG file by creating a circle and assign it to a layer. Layer is created and circle is drawn. Layer to the circle has been assigned. But for some reason the Color of the circle is always set to "ByBlock". I tried in different ways to set to ByLayer, but didn't work. The following is the code I'm trying. The same code works in DXF but not DWG. Can you please suggest what needs to be changed?

            CadDocument doc = new CadDocument();
            string dwgFilePath = "Output.dwg";
            Layer layer = new Layer("Test");
            layer.Color = new Color(25);
            doc.Layers.Add(layer);

            Circle c = new Circle();
            c.Center = new CSMath.XYZ(0, 0, 0);
            c.Radius = 10;

            c.Layer = layer;

            c.Color = Color.ByLayer;
            doc.ModelSpace.Entities.Add(c);

            using (DwgWriter writer = new DwgWriter(dwgFilePath, doc))
            {
                writer.Write();
            }
DomCR commented 11 months ago

Hi @nag-fdestech,

The issue seems to be a missing implementation in the DwgWriter to write the Entity color, I'll open a branch to fix this issue.