-
Notifications
You must be signed in to change notification settings - Fork 444
New DXF generator #843
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
base: master
Are you sure you want to change the base?
New DXF generator #843
Conversation
…rs directly through DXFSurface. The builder maps SVG-style commands into DXF entities: it converts cubic Béziers into true arcs when their control points lie on a common circle, otherwise flattens them into short chords; merges collinear line runs and contiguous arcs to reduce geometry; promotes closed all-arc runs to CIRCLE entities; and writes the rest as lightweight polylines with bulge values for arcs while attaching text as MTEXT.
|
Look like ezdxf is missing in the requirements.txt I also wonder if the path optimizations is something we want in general and not only for the dxf backend. I need to check the arc code. We are doing some funky stuff in there like splitting arcs and circles into smaller segments on purpose. Not sure if this really still needed. That might date back to the libcairo days. |
|
Also what is the motivation for the backend. Making things work without ps2edit or the the ps2edit output problematic for your machine? |
Fixed
I don't think that path optimization is something useful for other file formats. For DXF, it is kind of a must, because if you have too many lines in a single polyline it becomes impossible to edit. The other file formats I don't use, but as far as I know, there's no much editing after you export, and a laser machine doesn't care about arc or splines or a line segmented into many lines. That being said, path optimization is always welcome, but the way it is right now, I think it can be left as a side quest.
I couldn't make the ps2edit generate arcs and circles. At first I created the dogbone inner corners, and when I exported the dxf it was terrible. It wasn't that the ps2edit was problematic for my machine, it was that I couldn't see that dxf looking like that, hahahaha, but for real, I think that having the dxf backend natively in python is better than needing another software. |
… ezdxf header before assigning numeric values and type the attribute map as dict[str, Any] (boxes/dxf_generator.py (line 62), boxes/dxf_generator.py (line 68)); removed superfluous casts and ensured merged segments stay Segments, plus explicitly coerce command arguments to float/str for safe vector creation and text handling (boxes/dxf_generator.py (line 226), boxes/dxf_generator.py (line 654), boxes/dxf_generator.py (line 719)); kept the superclass call working by swapping the ignore code (boxes/dxf_generator.py (line 733)). Pre-commit also wanted requirements.txt alphabetised, so ezdxf moved up and the missing trailing newline was restored (requirements.txt (line 1)).
--format dxf now renders directly through DXFSurface. The builder maps SVG-style commands into DXF entities: it converts cubic Béziers into true arcs when their control points lie on a common circle, otherwise flattens them into short chords; merges collinear line runs and contiguous arcs to reduce geometry; promotes closed all-arc runs to CIRCLE entities; and writes the rest as lightweight polylines with bulge values for arcs while attaching text as MTEXT.
a16fd0c to
4f34f20
Compare
|
Can you please double check the line width. At least in Inkscape the lines are 0.756mm (2.857px) instead of 0.2mm. The pieces otoh have the right size in mm. The placement of the text seems to be off. Guess you don't support the |
|
Sure — I’ll try to address both as soon as I can. About the line width: in AutoCAD everything looks normal on my side, so this might be an Inkscape import/detail, but I’ll double-check what we’re actually writing into the DXF. For my workflow the exported geometry should basically be “centerlines”, i.e. line thickness ideally should not exist. If a DXF comes in with an actual width/weight, it can become annoying to edit in AutoCAD and can also cause issues when sending the file to process-planning/CAM software. What would you prefer for the DXF output?
Text placement: yes, I probably don’t map SVG-style center alignment correctly yet. I’ll fix the alignment mapping and re-test in Inkscape as well. |
|
Well, we are not actually using the line width in SVG either. The laser is supposed to cut in the line center. Line width is set to 2xburn so the line represents the material to be cut away and the remaining part is what's inside the line. If there are no reasons to keep the line at zero I'd just stick to that. Things working perfectly in Inkscape is not a priority but just what's easiest for me to check. Treat these things more like things to double check. But as I can't/haven't really done much proper testing I have re-added the old ps2edit output, so people can keep their work flow while we work out possible kinks in this backend. |
|
The line width should actually be part of the dat structure. So you don't nened to worry about how it relates to everything but just use the one in there. For now nothing uses different widths but that that doesn't have to stay that way. |
Adds the native DXF export path from master so --format dxf now renders directly through DXFSurface. The builder maps SVG-style commands into DXF entities: it converts cubic Béziers into true arcs when their control points lie on a common circle, otherwise flattens them into short chords; merges collinear line runs and contiguous arcs to reduce geometry; promotes closed all-arc runs to CIRCLE entities; and writes the rest as lightweight polylines with bulge values for arcs while attaching text as MTEXT.
DXF Generator Workflow
Segment Merging and Output
Additional Notes