gdsestimating / three-dxf Goto Github PK
View Code? Open in Web Editor NEWA dxf viewer for the browser using three.js
License: MIT License
A dxf viewer for the browser using three.js
License: MIT License
Hi
Website test images LR.pdf
, I have a pdf file with multiple dxf images. I have attached sample pdf. Please help me how to extract this pdf or any suggestions. Thanks
"ERROR in ./node_modules/three-dxf/src/index.js 472:36-47
"export 'Face3' (imported as 'THREE') was not found in 'three'"
during build time
Three.js version : 0.128.0
Three-dxf version : 1.0.1
We are using some deprecated functions/classes such as THREE.Projector
so we need to update the code with the latest version of Three.js
Trying to run the sample I get a redirection error:
Hit CTRL-C to stop the server
[Sun Aug 11 2019 17:55:39 GMT+0200 (GMT+02:00)] "GET /sample" "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:68.0) Gecko/20100101 Firefox/68.0"
[Sun Aug 11 2019 17:55:39 GMT+0200 (GMT+02:00)] "GET /sample/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:68.0) Gecko/20100101 Firefox/68.0"
[Sun Aug 11 2019 17:55:39 GMT+0200 (GMT+02:00)] "GET /sample//" "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:68.0) Gecko/20100101 Firefox/68.0"
[Sun Aug 11 2019 17:55:39 GMT+0200 (GMT+02:00)] "GET /sample///" "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:68.0) Gecko/20100101 Firefox/68.0"
[Sun Aug 11 2019 17:55:39 GMT+0200 (GMT+02:00)] "GET /sample////" "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:68.0) Gecko/20100101 Firefox/68.0"
[Sun Aug 11 2019 17:55:39 GMT+0200 (GMT+02:00)] "GET /sample/////" "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:68.0) Gecko/20100101 Firefox/68.0"
[Sun Aug 11 2019 17:55:39 GMT+0200 (GMT+02:00)] "GET /sample//////" "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:68.0) Gecko/20100101 Firefox/68.0"
[Sun Aug 11 2019 17:55:39 GMT+0200 (GMT+02:00)] "GET /sample///////" "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:68.0) Gecko/20100101 Firefox/68.0"
[Sun Aug 11 2019 17:55:39 GMT+0200 (GMT+02:00)] "GET /sample////////" "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:68.0) Gecko/20100101 Firefox/68.0"
[Sun Aug 11 2019 17:55:39 GMT+0200 (GMT+02:00)] "GET /sample/////////" "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:68.0) Gecko/20100101 Firefox/68.0"
[Sun Aug 11 2019 17:55:39 GMT+0200 (GMT+02:00)] "GET /sample//////////" "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:68
I tried uploading a 30 MB file into the sample project and Chrome crashed while loading it. Haven't tried other browsers yet.
I am trying to load the three-dxf script into my React app using below.
useEffect(() => {
const script = document.createElement("script");
script.type = 'text/javascript';
script.src = '/dist/three-dxf.js';
script.async = true;
script.onload = () => scriptLoaded();
document.getElementsByTagName('head')[0].appendChild(script);
});
The above does not give any error, however, inside the scriptLoaded function, when I try to load the ThreeDxf object from the window object, it gives undefined, i.e.
window.ThreeDxf.Viewer(...)
gives an error TypeError: Cannot read property 'Viewer' of undefined
Any idea why the window object does not contain ThreeDxf?
I am having an issue with LaswerWeb3 (same for LW2) not recognizing arcs from Autodesk Inventor correctly. Instead of the arc it puts 2 lines. And if I had a circle it would be represented as a square.
Pics and DXF attached. @openhardwarecoza
Thank you for this great project. It can open big dxf files faster than AutoCAD :) I have a project that it seems different in three-dxf in comparison with AutoCAD like this:
DXF file on three-dxf sample viewer:
DXF file on AutoCAD:
Object type of lines are "Block Referance". and some of lines are polylines. Is it because the object type is Block reference?
Sample showing a parsed result in canvas, How to show it in three.js scene.
Is it possible to show file results in 3D or 2D scenes.
Dxf-parser nearly supports this, so we should work on blocks in three-dxf in tandem.
I tried the sample as 'Run Samples' but got 'Uncaught TypeError: THREE.OrbitControls is not a constructor' in the console of Chrome.
What should I do?
Thanks for your help.
My browser crashed when I tried to render dxf file with size of 15MB. What could be the fix to it? Any help would be appreciated.
Last I remember, the viewport assumes it should be pointed at 0,0,0. This is a reasonable guess, but not always the case. I think we can parse viewport information and start there, or the dxf header may have some reasonable info for where we should point and what the extents of the cad drawing are.
When adding a dxf with 10.000 entities, there is a huge performance drop.
Every Entity produce a draw call on scene.add(obj).
Is it possible to merge the whole Geometry without loosing the single entity color?
index.js 中选择文件时有错。怎么解决。
Hi, I refactored three-dxf with typescript in my fork, can I open a pull request?
After the refactoring I also made some code bug fixes and optimizations:
We can discuss further if needed, thanks!
Hi
As part of my implementation of your library, as a CNC toolpath generator, it would be soooo much easier if we had the option to handle arcs/circles as line segments.
There is sample code https://github.com/chilipeppr/widget-3dviewer/blob/master/widget.js#L3163 but I am lost with all the math involved :(
First of all, thank you. I have another question. After it is converted into regular text, the text will be displayed as a question mark
NoNoHatchMtext.zip
So, I am pretty new to RequireJS, but I am trying to integrate your library into https://github.com/openhardwarecoza/widget-laserweb/blob/master/widget.js#L31
But lower down when I run https://github.com/openhardwarecoza/widget-laserweb/blob/master/widget.js#L528
It complains that DxfParser is not defined.
cadCanvas = new window.ThreeDxf.Viewer(dxf, document.getElementById('cad-view'), 400, 400, font);
causes an error in the console when I try to open a file. It cannot open property "Viewer" of undefined or null.
(When I load the site there is another error about an expected semicolon in three-dxf.js between "use-strict"; and eval(.)
Does anyone know why this happens and how I can fix it? It only happens on Internet Explorer 11. With Chrome and Edge everything works.
Edit:
I think I've fixed the Viewer undefined error by copying everything in the same file and <script> but it still doesn't work. Maybe the Error with the semicolon is the reason. Any help appreciated.
I believe there is only support for LWPolylines, so we need regular Polylines as well. Dxf-parser's latest version should support them already so it's just a matter of displaying them.
Getting this error trying to run this in Angular, tried installing types but like other posts had no success.
You may need an appropriate loader to handle this file type.
|
| this.texture = source.texture.clone();
| this.texture.image = { ...this.texture.image }; // See #20328.
|
| this.depthBuffer = source.depthBuffer;
@ ./~/three-dxf-loader/dist/three-dxf-loader.js 16:82-98
@ ./src/app/dxf-viewer/dxf-viewer.component.ts
@ ./src/app/app.module.ts
@ ./src/main.ts
Here's the TS file I'm calling it in:
import { Component, OnInit } from '@angular/core';
// import * as THREE from 'three'
import { ThreeDxf } from 'three-dxf-loader'
import DxfParser from 'dxf-parser'
@Component({
selector: 'app-dxf-viewer',
templateUrl: './dxf-viewer.component.html',
styleUrls: ['./dxf-viewer.component.css']
})
export class DxfViewerComponent implements OnInit {
private file: Blob;
public dxf;
public cadCanvas;
constructor() { }
ngOnInit() {
}
public handleFileInput(fileInput) {
this.file = fileInput.item(0) as Blob;
console.log(this.file instanceof Blob);
let fileReader = new FileReader();
fileReader.onload = function(e) {
const parser = new DxfParser();
try {
let dxf = parser.parseSync(e.target.result);
return dxf
} catch (err) {
return console.error(err.stack);
}
}
this.dxf = fileReader.readAsText(this.file);
}
public renderDxf() {
// var font;
// var loader = new THREE.FontLoader();
// loader.load( 'fonts/helvetiker_regular.typeface.json', function ( response ) {
// font = response;
// this.cadCanvas = new ThreeDxf.Viewer(this.dxf, document.getElementById('cad-view'), 1000, 800);
// });
this.cadCanvas = new ThreeDxf.Viewer(this.dxf, document.getElementById('cad-view'), 400, 400);
}
}
Any tips on what I should do? Thanks!
I am trying to get three-dxf to work on my liferay tomcat server. I believe I have dxf-parser.js
fully working and I have r79 of three.min.js
loaded.
When trying to display a dxf with the line
cadCanvas = new window.ThreeDxf.Viewer(dxf,document.getElementById('mainwrap'),400,400,font);
I get the error
Uncaught TypeError: (intermediate value).setFromPoints is not a function
at drawArc (index.js?b635:445)
at drawEntity (index.js?b635:212)
at new Viewer (index.js?b635:112)
at three.min.js:387
at XMLHttpRequest.<anonymous> (three.min.js:385)
I was able to get the sample working with the http-server, so I'm not sure why it doesn't work on this server. Is this an issue with the version of three.min.js
that I'm using?
Three-dxf renders dxf files in plan view. How to change it to elevation view?
Hy,
it's possible select layers (example dropdown list) and color single layer?
Hi! Thank you for that great library!
I have a problem with this dxf file: http://flowrez.prosto-tak.ru/test.dxf
It must look like http://flowrez.prosto-tak.ru/1.PNG
but its rendering like this: http://flowrez.prosto-tak.ru/2.PNG
i.e. circles not drawing correctly
could you, please, fix this problem?
I tried to modify it, but it didn't work
Sorry for my English. The problem is generated when the QuadraticBezierCurve3 class is instantiated:
curve = new THREE.QuadraticBezierCurve3 (points [i], points [i + 1], points [i + 2]);
FILE: src / index.js line 354
Use this file SPLINE3.zip
P.s .: The problem is also highlighted with QuadraticBezierCurve Function
Thank's
I have just checke out the repository and following the run sample instructions.
On loading a DXF file the page displays the JSON loaded structure but fails to render the DXF objects.
Console shows the following:
three-dxf.js:1 Uncaught TypeError: Cannot read properties of undefined (reading 'prototype') at three-dxf.js:1 (anonymous) @ three-dxf.js:1 index.js:59 progress index.js:60 100 index.js:92 Uncaught TypeError: Cannot read properties of undefined (reading 'Viewer') at index.js:92 at Object.onLoad (three.min.js:6) at XMLHttpRequest.<anonymous> (three.min.js:6)
Hi,
I have installed the component and it is great!
Now I would like to view all the dxf files from a directory.
I have these lines in php :
$directory = '\\\\pc0234\docs\data\01';
foreach(scandir($directory) as $file)
{
<div id="cad-view" name="<?php echo $directory . $file; ?>">
<?php echo $directory . $file; ?>
</div>
}
What do I have to change in the index.js?
Do you have any sample about this?
Thanks, best regards
I follow the Run Samples step by step
But when I open http://127.0.0.1/sample,I got the error response like below:
ERR_TOO_MANY_REDIRECTS
and the browser's address change to http://127.0.0.1:8080/sample///////////////////
I don know why.
Examples of text with inline font info
\\fArial;HEAD
to HEAD
{\\fArial|b0|i0|c0|p34;DETAIL G & DETAIL H}
to DETAIL G & DETAIL H
See also:
https://ezdxf.readthedocs.io/en/stable/dxfentities/mtext.html
https://github.com/dxfom/mtext
I want to edit file in canvas and want to store in system
Hi I tried to use sample.
but getting error :
@duncanthrax @vinzentvega
can anyone look at this please?
Sorry, beginner in Angular here. I got dxf-parser to install types by running npm install dxf-parser-typings
. But three-dxf shows this error after installing it:
Could not find a declaration file for module 'three-dxf'. .../ClientApp/node_modules/three-dxf/dist/three-dxf.js' implicitly has an 'any' type.
Try npm i --save-dev @types/three-dxf
if it exists or add a new declaration (.d.ts) file containing declare module 'three-dxf';
ts(7016)
I have tried running npm i --save-dev @types/three-dxf
, npm install @types/three-dxf
, and npm install three-dxf-typings
and it shows this error in the console:
npm ERR! code E404
npm ERR! 404 Not Found - GET http://registry.npmjs.org/three-dxf-typings - Not found
npm ERR! 404
npm ERR! 404 'three-dxf-typings@latest' is not in the npm registry.
npm ERR! 404 You should bug the author to publish it (or use the name yourself!)
npm ERR! 404
npm ERR! 404 Note that you can also install from a
npm ERR! 404 tarball, folder, http url, or git url.
Please help :(
When creating dxf file we can use "mirror" command. It does not change the shape of entity, but change z-extrusion direction, which is not taken to the account in your library when image is drawn.
In my work I make center of ellipce to be the [0,0], then command "curve" look like this:
var curve = new THREE.EllipseCurve( 0, 0, xrad, yrad, alpha, beta, false, rotation );
The trick is to use:
ctx.scale(1, Math.sign(z_extrussion));
while generating image for user, where z_extrussion
is our 230
line value.
All we have to do in the end is to move canvas zero position back to it's prewious position.
Thank you for reading :-)
Import DXF, missing text and filler missing
Hello bzuillsmith, I download your project, test it. And I find some questions.The function of toShapes doesn't work, all the word doesn't show in canvas. And do you know how to show the solid graphics in cavans? I find it doesn't show either. I'm looking forward for your reply.Thanks.
Please, add support to React. If I install the dxf-parse
, three
and three-dxf
, when I import all the modules in my React application:
import DxfParser from 'dxf-parser';
import * as THREE from 'three';
import * as ThreeDxf from 'three-dxf';
I receive an error, THREE is not defined
. This error happens because the module three-dxf
expect the THREE
on global scope:
<script src='https://cdnjs.cloudflare.com/ajax/libs/three.js/101/three.js'></script>
To solve this issue I had import the Dxf Parse and Three Dxf on my React component and the Three in the index.html
file. It could be cool to support React by default.
If I use this three-dxf user in angular SPA and have several calls to "new ThreeDxf.Viewer" I get an warning "Too many active WebGL contexts. Oldest context will be lost."
What is the best approach to clean up those webgl objects? should I somehow call dispose() on all three.js objects?
How to calculate length of polyline?
Thanks for your help
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.