dxfjs / writer

A JavaScript dxf generator written in TypeScript.
https://dxf.vercel.app
MIT License
83 stars 17 forks source link

Multiple DIMSTYLE issues #26

Closed Colatino closed 2 years ago

Colatino commented 2 years ago

When I add any number of DimStyles, the generated DXF document won't open on AutoCAD.

Inspecting the file I've found that there is an AcDbDimStyleTable subclass before each DIMSTYLE and this is causing the error.

As a workaround I changed the DxfDimStyle and DxfTable classes.

The DxfDimStyle class I commented this line:

dx.subclassMarker('AcDbDimStyleTable');

And on the DxfTable:

class DxfTable {
    constructor(name) {
        this.name = name;
        this.maxNumberEntries = 0;
        this.ownerObjectHandle = '0';
        this.handle = Handle.next();
        this.records = [];
    }
    dxify(dx) {
        dx.type('TABLE');
        dx.name(this.name);
        dx.handle(this.handle);
        dx.push(330, this.ownerObjectHandle);
        dx.subclassMarker('AcDbSymbolTable');
        dx.push(70, this.records.length);
        // Added this IF clause to ensure only one AcDbDimStyleTable
        if (this.name == "DIMSTYLE") {
            dx.subclassMarker('AcDbDimStyleTable');
        }
        for (const record of this.records)
            record.dxify(dx);
        dx.type('ENDTAB');
    }
}

This change allowed me to open the files on AutoCAD

tarikjabiri commented 2 years ago

Hi, Thank you for the report, you are right and its fixed in v2.3.5. Regards.