Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 46 additions & 0 deletions src/Metadata/LookupTables/Entities.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1256,6 +1256,52 @@ export const metadataLookupEntities: readonly ClassMetadata[] = [
"dxfName": "LINE",
"dxfSubClassName": "AcDbLine"
},
{
"typeName": "LwPolyline",
"baseTypeName": "Entity",
"properties": [
{
"propertyName": "constantWidth",
"valueCodes": [
43
],
"referenceType": 0
},
{
"propertyName": "elevation",
"valueCodes": [
38
],
"referenceType": 0
},
{
"propertyName": "flags",
"valueCodes": [
70
],
"referenceType": 0
},
{
"propertyName": "normal",
"valueCodes": [
210,
220,
230
],
"referenceType": 0
},
{
"propertyName": "thickness",
"valueCodes": [
39
],
"referenceType": 0
}
],
"systemVariables": [],
"dxfName": "LWPOLYLINE",
"dxfSubClassName": "AcDbPolyline"
},
{
"typeName": "Mesh",
"baseTypeName": "Entity",
Expand Down
36 changes: 36 additions & 0 deletions tests/IO/DXF/DxfReader.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { DxfReader } from '../../../src/IO/DXF/DxfReader.js';
import { ACadVersion } from '../../../src/ACadVersion.js';
import { DxfBinaryReader } from '../../../src/IO/DXF/DxfStreamReader/DxfBinaryReader.js';
import { encodeCadString, getDecoderEncodingLabel } from '../../../src/IO/TextEncoding.js';
import { LwPolyline } from '../../../src/Entities/LwPolyline.js';

const dxfAsciiFiles = getDxfAsciiFiles();
const dxfBinaryFiles = getDxfBinaryFiles();
Expand Down Expand Up @@ -122,6 +123,41 @@ describe('DxfReaderTests', () => {
expect(streamReader.find('layer-säöü')).toBe(true);
});

it('ReadLwPolylineSubclassFields', () => {
const data = createAsciiDxf([
'0', 'SECTION',
'2', 'HEADER',
'9', '$ACADVER',
'1', 'AC1015',
'0', 'ENDSEC',
'0', 'SECTION',
'2', 'ENTITIES',
'0', 'LWPOLYLINE',
'5', '1F',
'100', 'AcDbEntity',
'8', '0',
'100', 'AcDbPolyline',
'90', '2',
'70', '1',
'38', '5.0',
'39', '2.0',
'43', '0.5',
'10', '0.0', '20', '0.0',
'10', '10.0', '20', '0.0',
'0', 'ENDSEC',
'0', 'EOF',
], 'ANSI_1252');

const doc = new DxfReader(data).read();
const polyline = [...doc.entities].find(e => e instanceof LwPolyline) as LwPolyline;

expect(polyline.vertices.length).toBe(2);
expect(polyline.isClosed).toBe(true);
expect(polyline.elevation).toBe(5);
expect(polyline.thickness).toBe(2);
expect(polyline.constantWidth).toBe(0.5);
});

describe.each(dxfAsciiFiles.map(f => [f.fileName, f]))('ASCII: %s', (_name, test) => {
it('ReadHeaderAscii', () => {
const data = readFileAsUint8Array(test.path);
Expand Down