Closed danmarshall closed 6 years ago
FYI, we are moving towards arrays for both input to export functions, and arrays as output from import functions at JSCAD. This will take a little time to get right but till make models with 2D and 3D objects possible, as well as models with more than one object. Should be easier to understand as well.
Supporting polylines for the dxf export would definitely be helpful. In addition to @mdales situation it would also allow for some CAM software when generating gcode for a router/milling machine to be able to cut contours that allow for tool radius offsetting based on being inside or outside of the polyline, and being able to determine cut direction (CW/CCW) all of which matter when it comes to routing/milling cutting techniques.
@zrichmond Could you add a few thoughts to this issue for JSCAD as well? I’m about to rewrite the export for DXF.
After doing a little research, I've found:
So it looks like Maker.js aligns well with LWPOLYLINE. @zrichmond @mdales let me know if LWPOLYLINE will work for your scenarios.
@z3dev it appears the POLYLINE may be the better fit for JSCAD depending on the scenario. If you are outputting 2D then you may also look at LWPOLYLINE.
@danmarshall thanks for the information.
I’m planing on using LWPOLYLINE for 2D paths. Sadly, JSCAD doesn’t have the proper lines or line segments yet, which would be best as POLYLINE.
For 3D, I’m planning on using 3DFACE which is more efficient that other DXF entities.
(These are just my collection of LWPOLYLINE implementation / DXF file format footnotes from 3 hours of research)
Also, it appears that POLYLINE (not LW-) is part of the earlier R12 version, which may avoid having to add all these extra tables. In the case of Maker.js, most of the tables are just no-ops, other than the Layers table. So, I may end up backtracking and go with POLYLINE, if I can find a way to make it work for circular arcs.
Apologies @danmarshall, I've been away form the keyboard for a few days.
So, before I wrote the generaor, I was working off a design that I tweaked and then exported to DXF from Cut 2D software. If I look inside that design, then it is using POLYLINE, not LWPOLYLINE. I guess it could have been exported as R12, but Cut 2D didn't give me any options, I just went with the default.
I also know that in general I find the laser cutter tool I use seems to barf on later versions than R12, so if that's easier for you, then that seems to be a good option from my personal use case, though I appreciate not suitable for a broader audience perhaps.
I've put that original DXF file here incase it's of use as reference: https://gist.github.com/mdales/a2c84c3d4e640fb903b6fc4b7389e54e
My DXF knowledge is pretty minimal, my original request about POLYLINEs was based on comparing the output of maker.js with that DXF.
LWPOLYLINE and POLYLINE have line segments with BULG (arc segments). For POLYLINE, the BULG is added to each VERTEX.
@z3dev thanks!
@mdales Thanks for the feedback. I have just published a new version 0.9.82 with DXF Polyline feature. However, it seems to only work in some DXF viewers. Not all I have tested will open the file :( Can you go into a model in the playground and then:
DXF
download buttonUse POLYLINE
checkbox:
Generate
buttonDownload .DXF
buttonWhen you want to change your app to use POLYLINE, just add an options object like this to makerjs.exporter.toDXF(model, { usePOLYLINE: true })
The DXF export currently only does individual entities. Could add an option to detect chains and emit Polylines.