8000 The changes to the InstanceCount property of DxfClass are not reflected in the output. · Issue #664 · DomCR/ACadSharp · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

The changes to the InstanceCount property of DxfClass are not reflected in the output. #664

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

Open
woodbook666 opened this issue May 9, 2025 · 1 comment
Labels
bug Something isn't working

Comments

@woodbook666
Copy link

When I created a DXF or DWG file by adding WIPEOUT or IMAGE entities, the files displayed correctly when opened in AutoCAD. However, when opened with "DWG TrueView," a free tool from Autodesk, the DWG files did not display these entities, and the DXF files resulted in an error and could not be opened. After some investigation, I found that the cause was likely the values such as 281 and 91 defined in the CLASS section for WIPEOUT and WIPEOUTVARIABLES. Therefore, just before passing the CadDocument to the Writer, I tried to modify the class values as shown below.

foreach (var cadClass in doc.Classes)
{
    if (cadClass.DxfName.Equals("WIPEOUT", StringComparison.CurrentCultureIgnoreCase)
    || cadClass.DxfName.Equals("IMAGE", StringComparison.CurrentCultureIgnoreCase))
    {
        cadClass.IsAnEntity = true;
        cadClass.InstanceCount = 1;
    }
    else if (cadClass.DxfName.Equals("WIPEOUTVARIABLES", StringComparison.CurrentCultureIgnoreCase)
    || cadClass.DxfName.Equals("IMAGEDEF", StringComparison.CurrentCultureIgnoreCase))
    {
        cadClass.InstanceCount = 1;
    }
}

However, this change was not applied during output, and in the resulting DXF file, both group codes were set to 0. Is it not possible to modify the values in the CLASS section in this way? If I do want to change them, how should I go about it?
For reference, up to version 1.1.6, changes to IsAnEntity were applied correctly. However, InstanceCount remained at 0. In version 1.1.19, neither of the changes is applied.

@woodbook666 woodbook666 added the bug Something isn't working label May 9, 2025
@DomCR
Copy link
Owner
DomCR commented May 9, 2025

Hi @woodbook666,

There is a flag in the CadWriterConfiguration which sets if you want to reset the dxfClasses, but the way it works seems to be wrong if the instance count is relevant for some software.

If you are using the repo, you can check the method DxfClassCollection.UpdateDxfClasses and change the method AddOrUpdate which modifies the collection, if the dxf class exist it only overrides the InstanceCount, which it would be always 0 because is not counting the objects in the document.

I'll open a PR to fix this issue and set the instance count as it should.

Thanks for the report!

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

When branches are created from issues, their pull requests are automatically linked.

2 participants
0