Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ARES Commander Cad #474

Open
ChandrasekarML opened this issue Oct 16, 2024 · 8 comments · May be fixed by #490
Open

ARES Commander Cad #474

ChandrasekarML opened this issue Oct 16, 2024 · 8 comments · May be fixed by #490
Labels
bug Something isn't working

Comments

@ChandrasekarML
Copy link

While opening the output drawing, an error drawing file occurs and requires recovery. 
Input drawing file images are available, but output drawing file images are invisible.

sample code:
using ACadSharp.Examples;
using ACadSharp.IO;
using ACadSharp.Tables.Collections;
using ACadSharp.Tables;
using System;
using System.Diagnostics;
using System.Linq;
using ACadSharp.Entities;
using System.Xml.Linq;

namespace ACadSharp.Examples
{

public class Program
{
    static void Main(string[] args)
    {

        void OnNotification(object sender, NotificationEventArgs e)
        {
            Console.WriteLine($"Notification: {e.Message}");
        }

        const string sourceFile = "C:\\Users\\Balaji.t\\Videos\\INPUT5\\FILE\\INPUT.dwg";
        const string targetFile = "C:\\Users\\Balaji.t\\Videos\\INPUT5\\FILE\\OUTPUT.dwg";      
       
        CadDocument doc;

        using (DwgReader reader = new DwgReader(sourceFile))
        {
            doc = reader.Read();

        }
        

        void WriteDwg(string targetFile, CadDocument doc)
        {
          
            using (DwgWriter writer = new DwgWriter(targetFile, doc))
            {                 
                writer.OnNotification += OnNotification;
                writer.Write();
            }
        }

        WriteDwg(targetFile, doc);


    }
}

}
FILE.zip

@ChandrasekarML ChandrasekarML added the bug Something isn't working label Oct 16, 2024
@DomCR
Copy link
Owner

DomCR commented Oct 17, 2024

Hi @ChandrasekarML,

I can see that the file contains a dynamic block and an instance of that one.

Dynamic blocks are not yet supported and my guess is that is messing with the output file because the writer does not distinguish between dynamic and normal.

I'll take a look to see if I find a workaround to make this compatible.

Thanks for your report!

@ChandrasekarML
Copy link
Author

While opening the output drawing file, the drawing file requires recovery notification to appear in version 1.0.1.
The output drawing file opens properly in beta version 2.0.1.
But both version sample codes are the same.

What you tried sample code in below:

using ACadSharp;
using ACadSharp.Entities;
using ACadSharp.IO;
using System.Reflection.Metadata;
using System.Xml.Linq;

class Program
{
static void Main(string[] args)
{

    string dwgFilePath = "C:\\Users\\Balaji.t\\Videos\\INPUT5\\Test.dwg";

    CadDocument doc = new CadDocument();

    void OnNotification(object sender, NotificationEventArgs e)
    {
        Console.WriteLine($"Notification: {e.Message}");
    }

    //Create a line from the origin to the point (5, 5, 0)
    Line line = new Line
    {
        StartPoint = CSMath.XYZ.Zero,
        EndPoint = new CSMath.XYZ(5, 5, 0)
    };

    //doc.Entities.Add(pt);
    doc.Entities.Add(line);

    doc.Header.Version = ACadVersion.AC1032;


    using (DwgWriter writer = new DwgWriter(dwgFilePath, doc))
    {
        writer.OnNotification += OnNotification;
        writer.Write();
    }


}

}
FILE 1.zip

@ChandrasekarML
Copy link
Author

What is the status of the previous chat?

@DomCR
Copy link
Owner

DomCR commented Oct 29, 2024

After the version 2.0.1 the image references were added, that may be the cause of the problem.

Does ARES provide any kind of log about the error? I can only test the file with Autocad on my end.

@ChandrasekarML
Copy link
Author

ARES Commander Log in the command:

Info:Recover dwg file.
Error:Dwg file: DictionaryWithDefault (ACAD_PLOTSTYLENAME) should be Created (Test:)
Error:Dwg file: PrintStyle Normal should be Created (Test:)
Info:Total objects in the handle table found 59.
Info:Loaded objects 59 (with errors 0). Invalid objects 0.
Info:Total errors found during recover: 2.
Info:Check recovered database.
Error:Database header: System Variable "CMLSTYLE" should be Standard (Test:Invalid)
Error:Database header: System Variable "FACETRES" should be Set to 0.5 (Test:Not 0.01..10)
Error:TextStyleTableRecord(31): Is not dependent on a Reference, but ReferenceSymbolId ((4)) is not Null should be Set to Null (Test:Invalid)
Error:Dictionary(2A): Dictionary (ACAD_FIELDLIST) should be Removed (Test:FieldList)
Error:Dictionary(A): Entry object (2A) should be Removed (Test:Invalid)
Error:Layout(34): should be Set to True (Test:Invalid)
Error:MlineStyle(13): Segments amount 0 should be Set to 1 (Test:Not 1..16)
Info:65 objects checked
Info:Total errors found during check 7, fixed 7

Please try with ARES Commander any trial version.

@DomCR
Copy link
Owner

DomCR commented Oct 30, 2024

Seems that ARES is complaining about some default values and entries in the root dictionary that are not found.

I'll create a branch to fix the ones that appear on the log.

In the meantime it will help if you do this in your end and check if the log improves, for example, to fix the variable FACETRES I think is enough to make sure that is set to a value between 0.01 to 10.0.

There is one element that I don't recognize which is PrintStyle, not sure if it's the same as plotsettings.

Did you try to import a dxf instead of dwg to test if it has the same errors?

@ChandrasekarML
Copy link
Author

We try with dxfwriter, but we get an error. While opening the output drawing file, the drawing file requires a recovery notification to appear.

Sample code:

public void DrawLine(string filePath)
{
string dwgFilePath = Path.Combine(filePath, "Test.dxf");

CadDocument doc = new CadDocument();

void OnNotification(object sender, NotificationEventArgs e)
{
    Console.WriteLine($"Notification: {e.Message}");
}

//Create a line from the origin to the point (5, 5, 0)
Line line = new Line
{
    StartPoint = CSMath.XYZ.Zero,
    EndPoint = new CSMath.XYZ(5, 5, 0)
};

//doc.Entities.Add(pt);
doc.ModelSpace.Entities.Add(line);

doc.Header.Version = ACadVersion.AC1032;

//using (DwgWriter writer = new DwgWriter(dwgFilePath, doc))
//{
//    writer.OnNotification += OnNotification;
//    writer.Write();
//}
using (DxfWriter writer = new DxfWriter(dwgFilePath, doc, true))
{
    writer.Write();
}

}
DrawLine.zip

@DomCR
Copy link
Owner

DomCR commented Nov 13, 2024

The issue is the same as dwg, ARES is complaining about the default values.

Have you tried to change them as ARES says before saving the document?

@DomCR DomCR linked a pull request Nov 18, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants