From c28177c74b8081639cea15d9c567e9d310a8a3ce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sergio=20Pe=C3=B1alba=20Escudero?= Date: Mon, 14 May 2018 11:19:24 +0200 Subject: [PATCH 1/2] Stored the AutoCad color index in the layer data, updated tests to expect additional data --- dist/dxf-parser.js | 3 ++- lib/DxfParser.js | 3 ++- test/data/extendeddata.expected.json | 1 + test/data/layer-table.expected.json | 2 ++ 4 files changed, 7 insertions(+), 2 deletions(-) diff --git a/dist/dxf-parser.js b/dist/dxf-parser.js index 4f56bae..3331490 100644 --- a/dist/dxf-parser.js +++ b/dist/dxf-parser.js @@ -988,7 +988,8 @@ DxfParser.prototype._parse = function(dxfString) { case 62: // color, visibility layer.visible = curr.value >= 0; // TODO 0 and 256 are BYBLOCK and BYLAYER respectively. Need to handle these values for layers?. - layer.color = getAcadColor(Math.abs(curr.value)); + layer.colorIndex = Math.abs(curr.value); + layer.color = getAcadColor(layer.colorIndex); curr = scanner.next(); break; case 70: // frozen layer diff --git a/lib/DxfParser.js b/lib/DxfParser.js index 396e528..0ddb5cb 100644 --- a/lib/DxfParser.js +++ b/lib/DxfParser.js @@ -575,7 +575,8 @@ DxfParser.prototype._parse = function(dxfString) { case 62: // color, visibility layer.visible = curr.value >= 0; // TODO 0 and 256 are BYBLOCK and BYLAYER respectively. Need to handle these values for layers?. - layer.color = getAcadColor(Math.abs(curr.value)); + layer.colorIndex = Math.abs(curr.value); + layer.color = getAcadColor(layer.colorIndex); curr = scanner.next(); break; case 70: // frozen layer diff --git a/test/data/extendeddata.expected.json b/test/data/extendeddata.expected.json index c82bd3c..e809851 100644 --- a/test/data/extendeddata.expected.json +++ b/test/data/extendeddata.expected.json @@ -986,6 +986,7 @@ "name": "0", "frozen": false, "visible": true, + "colorIndex": 7, "color": 16777215 } } diff --git a/test/data/layer-table.expected.json b/test/data/layer-table.expected.json index e4bf7d4..95bd029 100644 --- a/test/data/layer-table.expected.json +++ b/test/data/layer-table.expected.json @@ -6,12 +6,14 @@ "frozen": false, "name": "0", "visible": true, + "colorIndex": 7, "color": 16777215 }, "Layer 1": { "frozen": true, "name": "Layer 1", "visible": true, + "colorIndex": 7, "color": 16777215 } } From 2389c36367fccc6d9a53f46b8d7fcb1b9afc953a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sergio=20Pe=C3=B1alba=20Escudero?= Date: Mon, 14 May 2018 11:19:48 +0200 Subject: [PATCH 2/2] Updated minor version --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 3587c3d..bc7261a 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "dxf-parser", - "version": "0.6.1", + "version": "0.7.0", "description": "Parse dxf files into a readable, logical js object.", "main": "index.js", "scripts": {