DomCR / ACadSharp

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

Error converting from DWG to DXF #250

Open ShadowGreg opened 9 months ago

ShadowGreg commented 9 months ago

I'm trying to convert a DWG to DXF. But the file saved is corrupted.

 public static void Main(string[] args) {
        var path = Ui.Prompt("Enter path to dwg file: ");
        CadDocument doc = DwgReader.Read(path);
        doc.Header.Version = ACadVersion.AC1018;
        var dxfPath = Ui.Prompt("Enter path to dxf file: ");
        using (DxfWriter writer = new DxfWriter(dxfPath, doc,false))
        {
            writer.OnNotification += NotificationHelper.LogConsoleNotification;
            writer.Write();
        }             
    }

Exception text in AutoCad When reading from HATCH, starting at line 3152, it was found the following error:

Error: Group code 47 expected Corrupt or incomplete input DXF file - drawing import failed.

Text in NotificationHelper

Entity type not implemented : ACadSharp.Entities.Wipeout Object not implemented : ACadSharp.Objects.SortEntitiesTable Object not implemented : ACadSharp.Objects.SortEntitiesTable Object not implemented : ACadSharp.Objects.SortEntitiesTable Object not implemented : ACadSharp.Objects.SortEntitiesTable Object not implemented : ACadSharp.Objects.SortEntitiesTable Object not implemented : ACadSharp.Objects.AcdbPlaceHolder
Object not implemented : ACadSharp.Objects.Scale
Object not implemented : ACadSharp.Objects.Scale
Object not implemented : ACadSharp.Objects.Scale
Object not implemented : ACadSharp.Objects.Scale
Object not implemented : ACadSharp.Objects.Scale
Object not implemented : ACadSharp.Objects.Scale
Object not implemented : ACadSharp.Objects.Scale
Object not implemented : ACadSharp.Objects.Scale
Object not implemented : ACadSharp.Objects.Scale Object not implemented : ACadSharp.Objects.Scale Object not implemented : ACadSharp.Objects.Scale Object not implemented : ACadSharp.Objects.Scale Object not implemented : ACadSharp.Objects.Scale Object not implemented : ACadSharp.Objects.Scale Object not implemented : ACadSharp.Objects.Scale Object not implemented : ACadSharp.Objects.Scale Object not implemented : ACadSharp.Objects.Scale

DomCR commented 9 months ago

Hi @ShadowGreg,

The type of the Hatch that you are trying to convert seems to be using the flooding method, which uses the variable PixelSize from the Hatch, that is not written at the moment.

I'll open a branch to fix this issue, could you provide the Dwg that you are trying to convert? or a copy of it with only the Hatch that is making if fail? it will help with the implementation.

Thanks!

ShadowGreg commented 9 months ago

4550.50.GS00.008.0155.362675.20.133AI.Sh01-37.Rev_a0.dwg.zip

DomCR commented 9 months ago

Your file seems to have characters in the Text and MText that the writer cannot process correctly, I'll create another branch to take a look at this second issue.

DomCR commented 9 months ago

PR that fixed the text format for Tolerance and MText but the dxf file produced by ACadSharp is still invalid in this particular case.