前端javascript:普通html以及vue中的用法 Dxf-Parser 读取dxf数据

2023-09-25 14 0

目录

一 简介和安装

二 vue详细用法

三 普通html用法

四 注意细节


遇到 Dxf-Parser 解析cad弧形数据  只会给你提供一个凸度数据  要解决  参考我的另一篇

一 简介和安装

链接

Dxf解析器

Dxf Parser是一个用于 dxf 文件的 javascript 解析器。它将 dxf 文件读入一个具有可读属性和更逻辑结构的大型 javascript 对象。

另外,请留意three-dxf,这是一个浏览器模块,用于在浏览器中呈现 Dxf-Parser 的输出。

安装

npm install dxf-parser

 

浏览器——从 0.1.3 开始,独立的 browserify 版本位于 dist/ 文件夹中。将其复制到安装目录之外或直接从 GitHub 存储库下载。我们最终可能会将其发布到 bower,但构建环境需要先做一些工作。

用法

// Grab fileText in node.js or browser
var fileText = ...;var parser = new DxfParser();
try {var dxf = parser.parseSync(fileText);
}catch(err) {return console.error(err.stack);
}

二 vue详细用法

 (1)引入

 (2)放一个上传按钮

(3)详细代码

document.getElementById("file-field").onchange = function() {var reader = new FileReader();reader.readAsText(this.files[0]);//reader.readAsText(this.files[0],"gbk");中文reader.onload = function(e) {var fileText = e.target.result;var parser = new DxfParser();var dxf = null;try {dxf = parser.parseSync(fileText);} catch(err) {return console.error(err.stack);}console.log('Success!', JSON.stringify(dxf, null, 4));};};

(4)结果打印

FilterContains.vue?7384:150 Success! {"header": {"$ACADVER": "AC1018","$ACADMAINTVER": 77,"$DWGCODEPAGE": "ANSI_936","$INSBASE": {"x": 0,"y": 0,"z": 0},"$EXTMIN": {"x": 38622148.034,"y": 3215843.663591779,"z": 0},"$EXTMAX": {"x": 38622193.53819916,"y": 3215874.814511329,"z": 0},"$LIMMIN": {"x": 0,"y": 0},"$LIMMAX": {"x": 120,"y": 80},"$ORTHOMODE": 1,"$REGENMODE": 1,"$FILLMODE": 1,"$QTEXTMODE": 0,"$MIRRTEXT": 1,"$LTSCALE": 0.5,"$ATTMODE": 1,"$TEXTSIZE": 0.2,"$TRACEWID": 0.05,"$TEXTSTYLE": "HZ","$CLAYER": "0","$CELTYPE": "CONTINUOUS","$CECOLOR": 256,"$CELTSCALE": 1,"$DISPSILH": 0,"$DIMSCALE": 1,"$DIMASZ": 0.18,"$DIMEXO": 0.0625,"$DIMDLI": 0.38,"$DIMRND": 0,"$DIMDLE": 0,"$DIMEXE": 0.18,"$DIMTP": 0,"$DIMTM": 0,"$DIMTXT": 0.18,"$DIMCEN": 0.09,"$DIMTSZ": 0,"$DIMTOL": 0,"$DIMLIM": 0,"$DIMTIH": 1,"$DIMTOH": 1,"$DIMSE1": 0,"$DIMSE2": 0,"$DIMTAD": 0,"$DIMZIN": 0,"$DIMBLK": "","$DIMASO": 1,"$DIMSHO": 0,"$DIMPOST": "","$DIMAPOST": "","$DIMALT": 0,"$DIMALTD": 2,"$DIMALTF": 25.4,"$DIMLFAC": 1,"$DIMTOFL": 0,"$DIMTVP": 0,"$DIMTIX": 0,"$DIMSOXD": 0,"$DIMSAH": 0,"$DIMBLK1": "","$DIMBLK2": "","$DIMSTYLE": "STANDARD","$DIMCLRD": 0,"$DIMCLRE": 0,"$DIMCLRT": 0,"$DIMTFAC": 1,"$DIMGAP": 0.09,"$DIMJUST": 0,"$DIMSD1": 0,"$DIMSD2": 0,"$DIMTOLJ": 1,"$DIMTZIN": 0,"$DIMALTZ": 0,"$DIMALTTZ": 0,"$DIMUPT": 0,"$DIMDEC": 4,"$DIMTDEC": 4,"$DIMALTU": 2,"$DIMALTTD": 2,"$DIMTXSTY": "STANDARD","$DIMAUNIT": 0,"$DIMADEC": 0,"$DIMALTRND": 0,"$DIMAZIN": 0,"$DIMDSEP": 46,"$DIMATFIT": 3,"$DIMFRAC": 0,"$DIMLDRBLK": "","$DIMLUNIT": 2,"$DIMLWD": -2,"$DIMLWE": -2,"$DIMTMOVE": 0,"$LUNITS": 2,"$LUPREC": 4,"$SKETCHINC": 0.1,"$FILLETRAD": 0,"$AUNITS": 0,"$AUPREC": 0,"$MENU": "ACAD","$ELEVATION": 0,"$PELEVATION": 0,"$THICKNESS": 0,"$LIMCHECK": 0,"$CHAMFERA": 0,"$CHAMFERB": 0,"$CHAMFERC": 0,"$CHAMFERD": 0,"$SKPOLY": 0,"$TDCREATE": 2459957.404187581,"$TDUCREATE": 2459957.070854247,"$TDUPDATE": 2459957.408480579,"$TDUUPDATE": 2459957.075147245,"$TDINDWG": 0.0020590741,"$TDUSRTIMER": 0.0020590741,"$USRTIMER": 1,"$ANGBASE": 0,"$ANGDIR": 0,"$PDMODE": 0,"$PDSIZE": 0.2,"$PLINEWID": 0,"$SPLFRAME": 0,"$SPLINETYPE": 5,"$SPLINESEGS": 8,"$HANDSEED": "444","$SURFTAB1": 6,"$SURFTAB2": 6,"$SURFTYPE": 6,"$SURFU": 6,"$SURFV": 6,"$UCSBASE": "","$UCSNAME": "","$UCSORG": {"x": 0,"y": 0,"z": 0},"$UCSXDIR": {"x": 1,"y": 0,"z": 0},"$UCSYDIR": {"x": 0,"y": 1,"z": 0},"$UCSORTHOREF": "","$UCSORTHOVIEW": 0,"$UCSORGTOP": {"x": 0,"y": 0,"z": 0},"$UCSORGBOTTOM": {"x": 0,"y": 0,"z": 0},"$UCSORGLEFT": {"x": 0,"y": 0,"z": 0},"$UCSORGRIGHT": {"x": 0,"y": 0,"z": 0},"$UCSORGFRONT": {"x": 0,"y": 0,"z": 0},"$UCSORGBACK": {"x": 0,"y": 0,"z": 0},"$PUCSBASE": "","$PUCSNAME": "","$PUCSORG": {"x": 0,"y": 0,"z": 0},"$PUCSXDIR": {"x": 1,"y": 0,"z": 0},"$PUCSYDIR": {"x": 0,"y": 1,"z": 0},"$PUCSORTHOREF": "","$PUCSORTHOVIEW": 0,"$PUCSORGTOP": {"x": 0,"y": 0,"z": 0},"$PUCSORGBOTTOM": {"x": 0,"y": 0,"z": 0},"$PUCSORGLEFT": {"x": 0,"y": 0,"z": 0},"$PUCSORGRIGHT": {"x": 0,"y": 0,"z": 0},"$PUCSORGFRONT": {"x": 0,"y": 0,"z": 0},"$PUCSORGBACK": {"x": 0,"y": 0,"z": 0},"$USERI1": 0,"$USERI2": 0,"$USERI3": 0,"$USERI4": 0,"$USERI5": 0,"$USERR1": 500,"$USERR2": 0,"$USERR3": 0,"$USERR4": 0,"$USERR5": 0,"$WORLDVIEW": 1,"$SHADEDGE": 3,"$SHADEDIF": 70,"$TILEMODE": 1,"$MAXACTVP": 16,"$PINSBASE": {"x": 0,"y": 0,"z": 0},"$PLIMCHECK": 0,"$PEXTMIN": {"x": 100000000000000000000,"y": 100000000000000000000,"z": 100000000000000000000},"$PEXTMAX": {"x": -100000000000000000000,"y": -100000000000000000000,"z": -100000000000000000000},"$PLIMMIN": {"x": 0,"y": 0},"$PLIMMAX": {"x": 12,"y": 9},"$UNITMODE": 0,"$VISRETAIN": 0,"$PLINEGEN": 1,"$PSLTSCALE": 0,"$TREEDEPTH": 3020,"$CMLSTYLE": "STANDARD","$CMLJUST": 0,"$CMLSCALE": 1,"$PROXYGRAPHICS": 1,"$MEASUREMENT": 1,"$CELWEIGHT": -1,"$ENDCAPS": 0,"$JOINSTYLE": 0,"$LWDISPLAY": true,"$INSUNITS": 0,"$HYPERLINKBASE": "","$STYLESHEET": "","$XEDIT": true,"$CEPSNTYPE": 0,"$PSTYLEMODE": true,"$FINGERPRINTGUID": "{FFB2FA09-98E8-49D7-9254-4DF6235AFA91}","$VERSIONGUID": "{4D33C72E-8116-4718-81DC-46EA06B7A447}","$EXTNAMES": true,"$PSVPSCALE": 0,"$OLESTARTUP": false,"$SORTENTS": 127,"$INDEXCTL": 0,"$HIDETEXT": 0,"$XCLIPFRAME": false,"$HALOGAP": 0,"$OBSCOLOR": 257,"$OBSLTYPE": 0,"$INTERSECTIONDISPLAY": 0,"$INTERSECTIONCOLOR": 257,"$DIMASSOC": 1,"$PROJECTNAME": ""},"tables": {"viewPort": {"handle": "8","ownerHandle": "0","viewPorts": [{"ownerHandle": "8","name": "*Active","lowerLeftCorner": {"x": 0,"y": 0},"upperRightCorner": {"x": 1,"y": 1},"center": {"x": 38622165.9628494,"y": 3215848.660539827},"snapBasePoint": {"x": 0,"y": 0},"snapSpacing": {"x": 1,"y": 1},"gridSpacing": {"x": 0,"y": 0},"viewDirectionFromTarget": {"x": 0,"y": 0,"z": 1},"viewTarget": {"x": 0,"y": 0,"z": 0},"lensLength": 50,"frontClippingPlane": 0,"backClippingPlane": 0,"snapRotationAngle": 0,"viewTwistAngle": 0,"renderMode": 0,"ucsOrigin": {"x": 0,"y": 0,"z": 0},"ucsXAxis": {"x": 1,"y": 0,"z": 0},"ucsYAxis": {"x": 0,"y": 1,"z": 0},"orthographicType": 0}]},"lineType": {"handle": "5","ownerHandle": "0","lineTypes": {"1161": {"name": "1161","description": "","pattern": [0,-1.6],"patternLength": 1.6},"7341": {"name": "7341","description": "","pattern": [1e-10,2],"patternLength": 2.0000000001},"7343": {"name": "7343","description": "","pattern": [1e-10,2],"patternLength": 2.0000000001},"10421": {"name": "10421","description": "","pattern": [2,1e-11],"patternLength": 2.00000000001},"10422": {"name": "10422","description": "","pattern": [2,2,1e-9],"patternLength": 4.000000001},"BYBLOCK": {"name": "BYBLOCK","description": "","patternLength": 0},"BYLAYER": {"name": "BYLAYER","description": "","patternLength": 0},"CONTINUOUS": {"name": "CONTINUOUS","description": "Solid line","patternLength": 0},"LINETYPE1": {"name": "LINETYPE1","description": "","pattern": [500,-0.1],"patternLength": 500.1},"X11": {"name": "X11","description": "","pattern": [5,-1],"patternLength": 6},"X12": {"name": "X12","description": "","pattern": [6,-1],"patternLength": 7},"X13": {"name": "X13","description": "","pattern": [10,-1],"patternLength": 11},"X14": {"name": "X14","description": "","pattern": [1,-0.6],"patternLength": 1.6},"X17": {"name": "X17","description": "","pattern": [10,-10],"patternLength": 20},"X18": {"name": "X18","description": "","pattern": [6,-6],"patternLength": 12},"X19": {"name": "X19","description": "","pattern": [5,-2,5],"patternLength": 12},"X20": {"name": "X20","description": "","pattern": [5,-7],"patternLength": 12},"X21": {"name": "X21","description": "","pattern": [2,-2],"patternLength": 4},"X22": {"name": "X22","description": "","pattern": [6,-1.199999999999999,1.6,-1.199999999999999],"patternLength": 10},"X23": {"name": "X23","description": "","pattern": [6,-2,6,-1.199999999999999,1.6,-1.199999999999999],"patternLength": 18},"X24": {"name": "X24","description": "","pattern": [6,-1.199999999999999,1.6,-1.199999999999999],"patternLength": 10},"X25": {"name": "X25","description": "","pattern": [6,-2,6,-1.199999999999999,1.6,-1.199999999999999],"patternLength": 18},"X27": {"name": "X27","description": "","pattern": [4,-2,2,-2],"patternLength": 10},"X16": {"name": "X16","description": "","pattern": [3.5,-1],"patternLength": 4.5},"X0": {"name": "X0","description": "","pattern": [3,-1],"patternLength": 4},"X1": {"name": "X1","description": "","pattern": [4,-1],"patternLength": 5},"X10": {"name": "X10","description": "","pattern": [6,-2,6,-1.333,0,-1.333,0,-1.333],"patternLength": 17.999},"X2": {"name": "X2","description": "","pattern": [8,-2],"patternLength": 10},"X3": {"name": "X3","description": "","pattern": [4,-1],"patternLength": 5},"X4": {"name": "X4","description": "","pattern": [0,-1.6],"patternLength": 1.6},"X5": {"name": "X5","description": "","pattern": [2,-1],"patternLength": 3},"X6": {"name": "X6","description": "","pattern": [1,-1],"patternLength": 2},"X7": {"name": "X7","description": "","pattern": [6,-1.333,0,-1.333,0,-1.333],"patternLength": 9.999},"X8": {"name": "X8","description": "","pattern": [6,-2,6,-2,0,-2],"patternLength": 18},"X9": {"name": "X9","description": "","pattern": [6,-2,0,-2],"patternLength": 10},"X15": {"name": "X15","description": "","pattern": [4,-2],"patternLength": 6},"X28": {"name": "X28","description": "","pattern": [0,-1],"patternLength": 1},"10422A": {"name": "10422A","description": "","pattern": [2,2],"patternLength": 4},"10421A": {"name": "10421A","description": "","pattern": [2,1e-11],"patternLength": 2.00000000001},"X26": {"name": "X26","description": "","pattern": [4,-1,4,-1,4,-1,0,-1],"patternLength": 16}}},"layer": {"handle": "2","ownerHandle": "0","layers": {"0": {"name": "0","frozen": false,"visible": true,"colorIndex": 7,"color": 16777215},"KZD": {"name": "KZD","frozen": false,"visible": true,"colorIndex": 1,"color": 16711680},"JMD": {"name": "JMD","frozen": false,"visible": true,"colorIndex": 6,"color": 16711935},"DLSS": {"name": "DLSS","frozen": false,"visible": true,"colorIndex": 4,"color": 65535},"GXYZ": {"name": "GXYZ","frozen": false,"visible": true,"colorIndex": 2,"color": 16776960},"DLDW": {"name": "DLDW","frozen": false,"visible": true,"colorIndex": 11,"color": 16744319},"ZBTZ": {"name": "ZBTZ","frozen": false,"visible": true,"colorIndex": 3,"color": 65280},"SXSS": {"name": "SXSS","frozen": false,"visible": true,"colorIndex": 5,"color": 255},"JJ": {"name": "JJ","frozen": false,"visible": true,"colorIndex": 2,"color": 16776960},"JZD": {"name": "JZD","frozen": false,"visible": true,"colorIndex": 1,"color": 16711680},"GCD": {"name": "GCD","frozen": false,"visible": true,"colorIndex": 1,"color": 16711680},"SJW": {"name": "SJW","frozen": false,"visible": true,"colorIndex": 1,"color": 16711680},"DGX": {"name": "DGX","frozen": false,"visible": true,"colorIndex": 2,"color": 16776960},"DSX": {"name": "DSX","frozen": false,"visible": true,"colorIndex": 2,"color": 16776960},"ZDH": {"name": "ZDH","frozen": false,"visible": true,"colorIndex": 1,"color": 16711680},"ZJ": {"name": "ZJ","frozen": false,"visible": true,"colorIndex": 7,"color": 16777215},"MJZJ": {"name": "MJZJ","frozen": false,"visible": true,"colorIndex": 4,"color": 65535},"TK": {"name": "TK","frozen": false,"visible": true,"colorIndex": 7,"color": 16777215},"DMTZ": {"name": "DMTZ","frozen": false,"visible": true,"colorIndex": 3,"color": 65280},"ASSIST": {"name": "ASSIST","frozen": false,"visible": true,"colorIndex": 7,"color": 16777215},"JZP": {"name": "JZP","frozen": false,"visible": true,"colorIndex": 1,"color": 16711680},"DLJ": {"name": "DLJ","frozen": false,"visible": true,"colorIndex": 2,"color": 16776960},"KCYDJ": {"name": "KCYDJ","frozen": false,"visible": true,"colorIndex": 1,"color": 16711680},"KCJZD": {"name": "KCJZD","frozen": false,"visible": true,"colorIndex": 1,"color": 16711680},"KCJZD_TXT": {"name": "KCJZD_TXT","frozen": false,"visible": true,"colorIndex": 1,"color": 16711680},"COMMUNITY": {"name": "COMMUNITY","frozen": false,"visible": true,"colorIndex": 1,"color": 16711680},"BASICGRID": {"name": "BASICGRID","frozen": false,"visible": true,"colorIndex": 5,"color": 255},"COMPONENT": {"name": "COMPONENT","frozen": false,"visible": true,"colorIndex": 4,"color": 65535},"NEW-�̵�": {"name": "NEW-�̵�","frozen": false,"visible": true,"colorIndex": 37,"color": 8347455}}}},"blocks": {"*MODEL_SPACE": {"handle": "5A","ownerHandle": "18","layer": "0","name": "*MODEL_SPACE","position": {"x": 0,"y": 0,"z": 0},"name2": "*MODEL_SPACE","xrefPath": ""},"*PAPER_SPACE": {"handle": "58","ownerHandle": "15","paperSpace": true,"layer": "0","name": "*PAPER_SPACE","position": {"x": 0,"y": 0,"z": 0},"name2": "*PAPER_SPACE","xrefPath": ""},"GC148": {"handle": "5C","ownerHandle": "1C","layer": "0","name": "GC148","position": {"x": 0,"y": 0,"z": 0},"name2": "GC148","xrefPath": "","entities": [{"type": "LINE","vertices": [{"x": -0.5,"y": 0,"z": 0},{"x": 0.5,"y": 0,"z": 0}],"handle": "5D","ownerHandle": "1C","layer": "0"},{"type": "LINE","vertices": [{"x": 0,"y": 0.5,"z": 0},{"x": 0,"y": -0.5,"z": 0}],"handle": "5E","ownerHandle": "1C","layer": "0"}]},"GC001": {"handle": "CC","ownerHandle": "1F","layer": "0","name": "GC001","position": {"x": 0,"y": 0,"z": 0},"name2": "GC001","xrefPath": "","entities": [{"type": "LINE","vertices": [{"x": -0.25,"y": 0,"z": 0},{"x": -0.25,"y": -0.5,"z": 0}],"handle": "CD","ownerHandle": "1F","layer": "0"},{"type": "LINE","vertices": [{"x": 0.25,"y": 0,"z": 0},{"x": 0.25,"y": -0.5,"z": 0}],"handle": "CE","ownerHandle": "1F","layer": "0"}]},"GC003": {"handle": "D0","ownerHandle": "20","layer": "0","name": "GC003","position": {"x": 0,"y": 0,"z": 0},"name2": "GC003","xrefPath": "","entities": [{"type": "LINE","vertices": [{"x": 0,"y": 0.8,"z": 0},{"x": 0,"y": 1.8,"z": 0}],"handle": "D1","ownerHandle": "20","layer": "0"},{"type": "LINE","vertices": [{"x": 0,"y": -1,"z": 0},{"x": 0,"y": 0,"z": 0}],"handle": "D2","ownerHandle": "20","layer": "0"}]},"GC077": {"handle": "D4","ownerHandle": "21","layer": "0","name": "GC077","position": {"x": 0,"y": 0,"z": 0},"name2": "GC077","xrefPath": "","entities": [{"type": "LINE","vertices": [{"x": 0,"y": 0,"z": 0},{"x": 0,"y": 1,"z": 0}],"handle": "D5","ownerHandle": "21","layer": "0"}]},"GC078": {"handle": "D7","ownerHandle": "22","layer": "0","name": "GC078","position": {"x": 0,"y": 0,"z": 0},"name2": "GC078","xrefPath": "","entities": [{"type": "LINE","vertices": [{"x": 0,"y": -1,"z": 0},{"x": 0,"y": 0,"z": 0}],"handle": "D8","ownerHandle": "22","layer": "0"}]},"GC081": {"handle": "DA","ownerHandle": "23","layer": "0","name": "GC081","position": {"x": 0,"y": 0,"z": 0},"name2": "GC081","xrefPath": "","entities": [{"type": "POINT","handle": "DB","ownerHandle": "23","layer": "0","position": {"x": 1.5,"y": 0.7,"z": 0}},{"type": "LINE","vertices": [{"x": 0,"y": 0,"z": 0},{"x": 0,"y": 1,"z": 0}],"handle": "DC","ownerHandle": "23","layer": "0"}]},"GC082": {"handle": "DE","ownerHandle": "24","layer": "0","name": "GC082","position": {"x": 0,"y": 0,"z": 0},"name2": "GC082","xrefPath": "","entities": [{"type": "LINE","vertices": [{"x": 0,"y": -1,"z": 0},{"x": 0,"y": 0,"z": 0}],"handle": "DF","ownerHandle": "24","layer": "0"},{"type": "POINT","handle": "E0","ownerHandle": "24","layer": "0","position": {"x": 1.5,"y": -0.7,"z": 0}}]},"GC151": {"handle": "E2","ownerHandle": "25","layer": "0","name": "GC151","position": {"x": 0,"y": 0,"z": 0},"name2": "GC151","xrefPath": "","entities": [{"type": "LINE","vertices": [{"x": 0,"y": -0.5,"z": 0},{"x": 0,"y": 0,"z": 0}],"handle": "E3","ownerHandle": "25","layer": "0"}]},"GC079": {"handle": "E5","ownerHandle": "26","layer": "0","name": "GC079","position": {"x": 0,"y": 0,"z": 0},"name2": "GC079","xrefPath": "","entities": [{"type": "LINE","vertices": [{"x": 1.5,"y": 0,"z": 0},{"x": 1.5,"y": 1,"z": 0}],"handle": "E6","ownerHandle": "26","layer": "0"},{"type": "LINE","vertices": [{"x": 0,"y": 0,"z": 0},{"x": 0,"y": 2,"z": 0}],"handle": "E7","ownerHandle": "26","layer": "0"}]},"GC080": {"handle": "E9","ownerHandle": "27","layer": "0","name": "GC080","position": {"x": 0,"y": 0,"z": 0},"name2": "GC080","xrefPath": "","entities": [{"type": "LINE","vertices": [{"x": 1.5,"y": -1,"z": 0},{"x": 1.5,"y": 0,"z": 0}],"handle": "EA","ownerHandle": "27","layer": "0"},{"type": "LINE","vertices": [{"x": 0,"y": -2,"z": 0},{"x": 0,"y": 0,"z": 0}],"handle": "EB","ownerHandle": "27","layer": "0"}]},"GC083": {"handle": "ED","ownerHandle": "28","layer": "0","name": "GC083","position": {"x": 0,"y": 0,"z": 0},"name2": "GC083","xrefPath": "","entities": [{"type": "POINT","handle": "EE","ownerHandle": "28","layer": "0","position": {"x": 1.5,"y": 1.5,"z": 0}},{"type": "LINE","vertices": [{"x": 1.5,"y": 0,"z": 0},{"x": 1.5,"y": 0.8,"z": 0}],"handle": "EF","ownerHandle": "28","layer": "0"},{"type": "LINE","vertices": [{"x": 0,"y": 2,"z": 0},{"x": 0,"y": 0,"z": 0}],"handle": "F0","ownerHandle": "28","layer": "0"}]},"GC084": {"handle": "F2","ownerHandle": "29","layer": "0","name": "GC084","position": {"x": 0,"y": 0,"z": 0},"name2": "GC084","xrefPath": "","entities": [{"type": "POINT","handle": "F3","ownerHandle": "29","layer": "0","position": {"x": 1.5,"y": -1.5,"z": 0}},{"type": "LINE","vertices": [{"x": 1.5,"y": 0,"z": 0},{"x": 1.5,"y": -0.8,"z": 0}],"handle": "F4","ownerHandle": "29","layer": "0"},{"type": "LINE","vertices": [{"x": 0,"y": 0,"z": 0},{"x": 0,"y": -2,"z": 0}],"handle": "F5","ownerHandle": "29","layer": "0"}]},"GC085": {"handle": "F7","ownerHandle": "2A","layer": "0","name": "GC085","position": {"x": 0,"y": 0,"z": 0},"name2": "GC085","xrefPath": "","entities": [{"type": "LINE","vertices": [{"x": 0,"y": -0.4,"z": 0},{"x": 0,"y": 0.4,"z": 0}],"handle": "F8","ownerHandle": "2A","layer": "0"}]},"GC005": {"handle": "100","ownerHandle": "2C","layer": "0","name": "GC005","position": {"x": 0,"y": 0,"z": 0},"name2": "GC005","xrefPath": "","entities": [{"type": "LWPOLYLINE","vertices": [{"x": -1.5,"y": -1},{"x": 1.5,"y": -1},{"x": 1.5,"y": 1},{"x": -1.5,"y": 1}],"handle": "101","ownerHandle": "2C","layer": "0","shape": true,"hasContinuousLinetypePattern": false}]},"GC131": {"handle": "108","ownerHandle": "2D","layer": "0","name": "GC131","position": {"x": 0,"y": 0,"z": 0},"name2": "GC131","xrefPath": "","entities": [{"type": "LINE","vertices": [{"x": -5,"y": 5,"z": 0},{"x": 5,"y": -5,"z": 0}],"handle": "109","ownerHandle": "2D","layer": "0"},{"type": "LINE","vertices": [{"x": -5,"y": -5,"z": 0},{"x": 5,"y": 5,"z": 0}],"handle": "10A","ownerHandle": "2D","layer": "0"},{"type": "LINE","vertices": [{"x": -5,"y": 5,"z": 0},{"x": -5,"y": -5,"z": 0}],"handle": "10B","ownerHandle": "2D","layer": "0"},{"type": "LINE","vertices": [{"x": 5,"y": 5,"z": 0},{"x": -5,"y": 5,"z": 0}],"handle": "10C","ownerHandle": "2D","layer": "0"},{"type": "LINE","vertices": [{"x": 5,"y": -5,"z": 0},{"x": 5,"y": 5,"z": 0}],"handle": "10D","ownerHandle": "2D","layer": "0"},{"type": "LINE","vertices": [{"x": -5,"y": -5,"z": 0},{"x": 5,"y": -5,"z": 0}],"handle": "10E","ownerHandle": "2D","layer": "0"}]},"GC007": {"handle": "11C","ownerHandle": "30","layer": "0","name": "GC007","position": {"x": 0,"y": 0,"z": 0},"name2": "GC007","xrefPath": "","entities": [{"type": "LINE","vertices": [{"x": 0,"y": -1.1,"z": 0},{"x": 0,"y": 0.3,"z": 0}],"handle": "11D","ownerHandle": "30","layer": "0"}]},"GC009": {"handle": "125","ownerHandle": "32","layer": "0","name": "GC009","position": {"x": 0,"y": 0,"z": 0},"name2": "GC009","xrefPath": "","entities": [{"type": "LINE","vertices": [{"x": 0,"y": -0.9,"z": 0},{"x": 0,"y": 0.3,"z": 0}],"handle": "126","ownerHandle": "32","layer": "0"}]},"GC200": {"handle": "142","ownerHandle": "141","layer": "0","name": "GC200","position": {"x": 0,"y": 0,"z": 0},"name2": "GC200","xrefPath": "","entities": [{"type": "LWPOLYLINE","vertices": [{"x": -0.1,"y": 0,"bulge": 1},{"x": 0.1,"y": 0,"bulge": 1}],"handle": "143","ownerHandle": "141","layer": "0","lineType": "Continuous","shape": true,"hasContinuousLinetypePattern": true,"width": 0.2}]},"GC0850": {"handle": "20D","ownerHandle": "20C","layer": "0","name": "GC0850","position": {"x": 0,"y": 0,"z": 0},"name2": "GC0850","xrefPath": "","entities": [{"type": "LINE","vertices": [{"x": 0,"y": -0.25,"z": 0},{"x": 0,"y": 0.25,"z": 0}],"handle": "20E","ownerHandle": "20C","layer": "0","lineType": "Continuous"}]},"GC0000": {"handle": "21D","ownerHandle": "21C","layer": "0","name": "GC0000","position": {"x": 0,"y": 0,"z": 0},"name2": "GC0000","xrefPath": "","entities": [{"type": "POINT","handle": "21E","ownerHandle": "21C","layer": "0","lineType": "Continuous","position": {"x": 0,"y": 0,"z": 0}}]}},"entities": [{"type": "LWPOLYLINE","vertices": [{"x": 38622158.6942034,"y": 3215865.687626693},{"x": 38622158.6942034,"y": 3215865.687626693,"bulge": 0.3804318421327185},{"x": 38622153.73793108,"y": 3215862.485707551},{"x": 38622151.33659461,"y": 3215862.918354233},{"x": 38622150.85784622,"y": 3215860.261137646},{"x": 38622152.03883137,"y": 3215860.048360589},{"x": 38622151.45369447,"y": 3215856.800651427},{"x": 38622150.37112476,"y": 3215856.995697063},{"x": 38622148.76453457,"y": 3215855.679715681},{"x": 38622148.034,"y": 3215851.625},{"x": 38622192.22252771,"y": 3215843.663591779},{"x": 38622193.53819916,"y": 3215850.966016621},{"x": 38622191.2746443,"y": 3215851.373839314},{"x": 38622191.59380988,"y": 3215853.145317039},{"x": 38622190.19631078,"y": 3215853.397103224},{"x": 38622193.51740601,"y": 3215871.830313103},{"x": 38622176.95408929,"y": 3215874.814511329},{"x": 38622175.60650126,"y": 3215867.334938713},{"x": 38622177.32877127,"y": 3215867.024638839},{"x": 38622176.99187427,"y": 3215865.154745685},{"x": 38622162.32797532,"y": 3215867.796727478},{"x": 38622161.84568067,"y": 3215865.119827804},{"x": 38622158.69638692,"y": 3215865.68723329}],"handle": "432","ownerHandle": "18","layer": "NEW-�̵�","lineType": "Continuous","colorIndex": 6,"color": 16711935,"shape": true,"hasContinuousLinetypePattern": true}]
}

三 普通html用法

<!DOCTYPE html>
<html><head><title>Dxf-Parser - Browser Sample</title><script src="../../dist/dxf-parser.js"></script></head><body><input id="file-field" type="file"/><pre id="output" stlye="font-family: monospace;"></pre><script>var outputElement = document.getElementById('output');document.getElementById("file-field").onchange = function() {var reader = new FileReader();reader.readAsText(this.files[0]);reader.onload = function(e) {var fileText = e.target.result;var parser = new DxfParser();var dxf = null;try {dxf = parser.parseSync(fileText);} catch(err) {return console.error(err.stack);}console.log('Success!');outputElement.innerHTML = JSON.stringify(dxf, null, 4);};};</script></body>
</html>

四 注意细节

后台arcmap把dxf数据转换的图形

 前端解析的坐标串数据解析成图形 通过后台代码绘制的

高亮图形是前端解析的  就差一个弧度差异 其他支持良好

导致高亮图斑弧形线没有的情况是 因为arcmap的不支持弧形绘制,Dxf-Parser 解析只会给你提供一个凸度数据  所以想要解决  参考我的另一篇

代码编程
赞赏

相关文章

零基础学习游戏建模多久能出师?3D建模师告诉你如何有效的学会建模
学3D建模一定要有美术功底?有则锦上添花,没有也不影响你学习
3D建模难学吗?零基础学6个月,能否找到工作?
3D建模入行难不难?零基础学习次世代,这6条建议能帮到你
游戏建模师薪资能给到多少?建模初学者如何快速入行,获取涨薪机会?
游戏建模行业门槛真有这么高?教你如何学习,找到合适自己的方式