Identifying Open Contours in .DXF and .SVG Files with QCAD/CAM Before Nesting

Discussions around the CAM Add-On of QCAD.

Moderator: andrew

Forum rules

Always indicate your operating system and QCAD version.

Indicate the post processor used.

Attach drawing files and screenshots.

Post one question per topic.

Post Reply
estibalizEchevarria
Registered Member
Posts: 2
Joined: Fri Feb 23, 2024 9:27 am

Identifying Open Contours in .DXF and .SVG Files with QCAD/CAM Before Nesting

Post by estibalizEchevarria » Fri Feb 23, 2024 10:14 am

Greetings,

Our team is currently tackling a project that involves utilizing QCAD/CAM for the preparation of .DXF and .SVG files intended for nesting. We've hit a snag due to open contours in our files. If a contour remains open, the nesting command disrupts the integrity of the piece, leading to the program running indefinitely. It's crucial for us to verify that all contours are sealed before proceeding to the nesting phase to circumvent this issue.
This is the piece:
Piece.png
Piece image
Piece.png (2.44 KiB) Viewed 2196 times
nesting image:
nesting.png
nesting image
nesting.png (6.36 KiB) Viewed 2196 times
Does anyone have experience or knowledge on how to effectively identify open contours within .DXF and .SVG files using QCAD/CAM? Furthermore, is there a specific parameter within the nesting command that can help avoid this problem?

For context, we are operating on Ubuntu 22.04 running in a docker, utilizing QCAD version 3.29.3 pro-linux-x86_64. The process is tailored for arranging pieces into various trays

Thank you in advance for your help
Attachments
out_10mm_0.dxf
nesting .dxf file
(392.69 KiB) Downloaded 54 times
E3TEOX4000bandeja-6SETAD22mm 1.dxf
piece .dxf file
(102.52 KiB) Downloaded 48 times

User avatar
andrew
Site Admin
Posts: 9063
Joined: Fri Mar 30, 2007 6:07 am

Re: Identifying Open Contours in .DXF and .SVG Files with QCAD/CAM Before Nesting

Post by andrew » Fri Feb 23, 2024 11:03 am

Normally, for these types of drawing, I'd recommend to work with polylines to ensure that all contours are closed. However, your drawings have overlaps which makes this difficult:
overlap.png
overlap.png (67.02 KiB) Viewed 2178 times
These overlaps are so consistent, that I suspect that this might be intended / required. Can you confirm this?

The nesting algorithm cannot identify which contours are inside others if the outer contour is not closed.

One workaround (while keeping the overlaps) would be to create blocks from your pieces. A block is a group of entities and always kept together by the nesting algorithm.

CVH
Premier Member
Posts: 3480
Joined: Wed Sep 27, 2017 4:17 pm

Re: Identifying Open Contours in .DXF and .SVG Files with QCAD/CAM Before Nesting

Post by CVH » Fri Feb 23, 2024 1:27 pm

andrew wrote:
Fri Feb 23, 2024 11:03 am
These overlaps are so consistent ...
Indeed very remarkable ... Consistent in their distance between endpoints equal to about 0.300.

But after some investigation most consistent in the Arc length ... The length along the curve of the arc:
Varying only in the last digit: 0.29999998 - 0.29999991 - 0.29999993
What is a match with the linear overlap of 0.30000000 for the outer contour.

I also detect other not near rounded values probably originating from a single precision system.

May I ask what the source of these shapes are ?
I can think of one source that fits.
G1 and G2/3 moves in G-Code with a 0.300mm overcut (The file is in drawing unit 'None')
And that may fit with the single precision notation too.

I have developed custom tools for fixing such issues in files provided by customers:
- Detect overlapping line and arcs, optional with fixing.
- Merge connected in-line line segments and co-circular arcs segments.

Fixing the given example file was thus child's play :wink:
Meanwhile fixed the single precision inaccuracies with yet another custom QCAD tool.
That could not perfectly re-position the 7.5mm wide slots and some manual tweaking was required :oops: .
Also centered the shape around the drawing origin instead of near (6358.1160, 518.9660) what is beneficial for the overall accuracy.

E3TEOX4000bandeja-6SETAD22mm 1 - Fixed.dxf
(100.95 KiB) Downloaded 44 times

PS: Also remark the odd length of the slots, this is because the centers of the semicircles are intended to be 3mm apart in X and in Y.
sqrt(3^2+3^2)+7.5 = 11.742640...mm
That is only steady in the neat squared out layout after re-positioning in the fixed file.

Regards,
CVH

estibalizEchevarria
Registered Member
Posts: 2
Joined: Fri Feb 23, 2024 9:27 am

Re: Identifying Open Contours in .DXF and .SVG Files with QCAD/CAM Before Nesting

Post by estibalizEchevarria » Mon Feb 26, 2024 1:14 pm

Hello,

Thank you very much for the replies. The overlaps are a result of the manual creation process; they are likely to be inconsistent and vary slightly in dimension and position. This is repeated in every piece that we are analyzing. Thus, it is something we cannot avoid because we do not make the pieces; they are sent to us to be nested into tray dimensions.

The nesting is done using multiple copies of that piece or different pieces. To do this, we use a program that creates a new .dxf file where all the pieces for nesting are grouped, and we assign each piece to a layer. For example, if there are four copies of the same piece, each piece corresponds to one layer. We also add a layer called "tray" because the nesting has to be done within that tray area. Therefore, the merged .dxf file has the layers: "tray," "piece1," "piece2," "piece3," etc. In the image, each color corresponds to one layer, therefore still to one piece, and it still does not consider it as a whole entity.

It is the client's responsibility to check that the piece is well-drawn, but human mistakes can happen, and we want to detect those mistakes. Is it possible to automatically detect overlaps in ARCS, POLYLINES, LINES, etc.? And if so, can detecting overlaps ensure that the piece is fully closed? Is there a tool to automatically connect line segments and arc segments and fix the piece so the nesting can be done? Is it possible to do it with QCAD, or do we need another tool?

CVH
Premier Member
Posts: 3480
Joined: Wed Sep 27, 2017 4:17 pm

Re: Identifying Open Contours in .DXF and .SVG Files with QCAD/CAM Before Nesting

Post by CVH » Mon Feb 26, 2024 2:41 pm

Hi,

IMHO a single and very consistent overlap of give or take 0.300 at arbitrary orientation for each closed contour is not a manual creation process.
Also, it occurs as linear overlap for straight edges and exactly the same as arc length for curved edges.

For an accidental mistake it is too consistent in nature :!:
estibalizEchevarria wrote:
Mon Feb 26, 2024 1:14 pm
Is it possible to automatically detect overlaps in ARCS, POLYLINES, LINES, etc.? And if so, can detecting overlaps ensure that the piece is fully closed?
Not straight out of the box, but as explained I have some custom tools to solve some things to the extent possible.
I am a CNC engraver myself and developed them for repairing customer files, but the tools are not 100% reliable ... If that is even possible :?
estibalizEchevarria wrote:
Mon Feb 26, 2024 1:14 pm
And if so, can detecting overlaps ensure that the piece is fully closed?
No, because beside the overlap there were discontinuities at connection points probably originating from single precision.
In some to more cases QCAD will consider these points to be practically connected and merge them disregarding one of both.
Line segments can then slant a bit, arcs become slightly deformed (center, radius, start- and end angle).

For the example file: Things were not squared out, the round corners of the external contour did not connect, the entities of the slots did not connect, each slots differs in size, the arcs making up a circle did not share the same center and radius ... and so on.
I agree, the differences are very minute but they are all solved in the fixed file.
estibalizEchevarria wrote:
Mon Feb 26, 2024 1:14 pm
Is there a tool to automatically connect line segments and arc segments ...
Yes, Polyline from Segments(OG) and Polyline from Selection(OC).
Both tools exploit a form of connect tolerance, one can increase that with the issues mentioned above.
OC can also bridge larger gaps with adding a straight line-segment, not per definition in-line or tangent.
estibalizEchevarria wrote:
Mon Feb 26, 2024 1:14 pm
... connect line segments and arc segments and fix the piece so the nesting can be done?
Automatically fixing the partially overlapping nature is not possible.
QCAD can not invent how the pieces should look like, it doesn't recognizes shapes as we do, all are but unrelated line-art segments.

- - - - - - - -

A manual work around is selecting a group of entities and merge them to a single Polyline with OC.
Keep the connect tolerance low to avoid larger distortions, see App.Prefs. .. Draw .. Polyline from Selection
If these segments make up a closed contour then the resulting Polyline will be logically closed (Only for OC).
Select the new Polyline and see the Closed property in the Property Editor.
If not logically closed then have a detailed look at the selected Polyline, especially near the red start Reference Marker.
It is there that the overlap (or gap) will occur after merging.

After fixing one such piece, nest it N times instead of fixing all the copies one by one. :wink:
And yes, It has happened that I rejected the customer drawing file(s).

Regards,
CVH

Post Reply

Return to “QCAD/CAM”