-
Notifications
You must be signed in to change notification settings - Fork 266
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to export DXF file by canvas info #579
Comments
Hi @tranthaihoang, The quick answer:
To show this in action, I've put this together in an Observable notebook: HTML Canvas to DXF. So please check that out - it even has your sample code above. The long answer:If one wanted to do this in Maker.js, there would be some refactoring involved. First, check out the documentation. The main concept that is different than Canvas is that Maker.js does not have a "turtle". Instead, you draw in discrete segments (path objects) that do not need to be contiguous as you create them.
The next thing is that one might not need to do so much math as in your example. The API documentation shows a wealth of functions to do math for you. So you can focus on the ideas from a more declarative level. Conversion from Canvas to Maker.jsUse the control points of the Canvas commands to create a series of lines: var line1 = new makerjs.paths.Line([x2, y2], [x4, y4]);
var line2 = new makerjs.paths.Line([x4, y4], [x5, y5]);
var line3 = new makerjs.paths.Line([x5, y5], [x3, y3]); The arcTo canvas command can be replaced by the Maker.js fillet function: var fillet1 = makerjs.path.fillet(line1, line2, r_val3);
var fillet2 = makerjs.path.fillet(line2, line3, r_val3); The fillet function will trim the line's endpoints to match the arc. Note there is a behavior difference when the radius of the arc is larger than the wedge defined by the control points:
Hope that helps! |
Hi @danmarshall Link codepen: https://codepen.io/thaihoangtran/pen/WNPwooO |
I have technical drawing parameters drawn through the HTML5 canvas function, is there a way to quickly convert these parameters so that they can be exported to a DXF file?
I saw a similar issue but it doesn't seem to have resolved the issue in question.
#447
I hope someone has solved it and provided guidance.
A sample code:
The text was updated successfully, but these errors were encountered: