How can I ensure that a path is uninterrupted?

Use this forum to ask questions about how to do things in QCAD.

Moderator: andrew

Forum rules

Always indicate your operating system and QCAD version.

Attach drawing files and screenshots.

Post one question per topic.

Post Reply
alexbottoni
Newbie Member
Posts: 9
Joined: Wed Nov 26, 2014 5:21 pm

How can I ensure that a path is uninterrupted?

Post by alexbottoni » Wed Nov 26, 2014 7:12 pm

Hi All,
I have to programmatically create a large amount of 2D drawings for a laser cutting project and I'm trying to use QCAD and its ECMAScript interface for this task (no code yet, just few drawings). Each drawing will be different from any other so no manual tweaking or optimization "at the source" is possible. Each operation must be performed by code.

In particular, each drawing must be generated by concatenating a small number of sub-drawings (that is: QCAD Blocks) and, of course, the resulting block or drawing must be composed by continuous (uninterrupted) lines/curves/paths that a laser cutter could follow without problems.

How can I be sure that the result of my assembly operation is a continuous path? Is there any programmatic way to perform a check 'n fix?

I do not see any "automagically connect all selected entities" command in QCAD's menu so I understand I should perform my checks/fixes by hand. Unfortunately, this is not possible in this case because of the large amount of drawings I have to handle.

Does anybody know of any dependable way to create a laser-cuttable, smooth and uninterrupted path using the ECMAScript interface of QCAD (by concatenating a small set of blocks/entities into a larger block/drawing)?

Thanks in advance.

User avatar
Clive
Moderator
Posts: 1329
Joined: Thu Aug 25, 2011 9:28 pm
Location: UK

Re: How can I ensure that a path is uninterrupted?

Post by Clive » Wed Nov 26, 2014 8:43 pm

Hi alexbottoni and welcome
alexbottoni wrote:In particular, each drawing must be generated by concatenating a small number of sub-drawings (that is: QCAD Blocks) and, of course, the resulting block or drawing must be composed by continuous (uninterrupted) lines/curves/paths that a laser cutter could follow without problems.
The easiest way to link your sub drawings/blocks is to place them on their own independent layer, most modern laser cutters will be able to 'map' the layers and carry out the cut or etch requirements in sequence.Blocks will have to be exploded in order to set the correct line weight needed as per the laser cutters specific needs, all entities within a block need to be able to be selected!

When you say 'continuous' I presume you mean lines,arcs etc.. without the control points or nodes? All laser cutters will quite easily follow any single or continuous lines - please explain more about this.
For the best support please state your operating system, QCAD version and add any supporting DXF/DWG files, screenshots etc...

alexbottoni
Newbie Member
Posts: 9
Joined: Wed Nov 26, 2014 5:21 pm

Re: How can I ensure that a path is uninterrupted?

Post by alexbottoni » Wed Nov 26, 2014 9:52 pm

Hi Clive,
thanks for your attention.

>>The easiest way to link your sub drawings/blocks is to place them on their own independent layer, most modern laser cutters will be able to 'map' the layers and carry out the cut or etch requirements in sequence.<<

OK, nice. I apologize for my ignorance but I'm quite new to laser cutting.

>>Blocks will have to be exploded in order to set the correct line weight needed as per the laser cutters specific needs, all entities within a block need to be able to be selected!<<

OK. This should not be a problem. I need blocks only to store them in a manageable way in an external file and to position them into the host drawing with a single operation. After that, I should be able to select and explode them before saving/outputting the resulting dxf file. The line width should always be the same (we will cut throught the metal all of the drawing lines. No etching altogether).

>>When you say 'continuous' I presume you mean lines,arcs etc.. without the control points or nodes? All laser cutters will quite easily follow any single or continuous lines - please explain more about this.<<

At the moment, I'm dealing mainly with straight lines and arcs (no control points and no nodes). Unfortunately, I cannot be sure I will not stumble upon any spline in the future. Could splines be a problem? Have I to approximate them with sequences of lines and arcs?

My main doubt is related to the fact that I have to insert a block between two other elements in a chain (the first and last elements of the chain are fixed. I just insert a set of other elements in the middle). It looks like I can link my block to the previous element of the chain (using a snap, while positioning it) but I'm still not able to see any easy way to link my block to the next (final and fixed) element of the sequence. I would need some "intelligent" way to join them without human supervision. Something like a "smart trim" or a "smart join" that I could use from code in a dependable way.

Thanks again for you help.

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

Re: How can I ensure that a path is uninterrupted?

Post by andrew » Wed Nov 26, 2014 10:21 pm

Hi Alex.

Can you maybe attach a screenshot or drawing file that illustrates the problem?

As far as combining different drawings into one goes: Are you aware of the QCAD command line tool 'merge'?
This command line tool merges different drawing files into one, based on an XML input file.

For more information about merge, please refer to:
http://www.qcad.org/en/qcad-documentati ... line-tools

If I understand your task at hand correctly, this might be a good starting point. The merge tool is entirely implemented in ECMAScript under scripts/Tools/MergeDrawings/MergeDrawings.js

alexbottoni
Newbie Member
Posts: 9
Joined: Wed Nov 26, 2014 5:21 pm

Re: How can I ensure that a path is uninterrupted?

Post by alexbottoni » Thu Nov 27, 2014 12:12 am

Hi Andrew,
thanks for your attention.

>> Can you maybe attach a screenshot or drawing file that illustrates the problem?<<

Yep, I'll try to post an example tomorrow (now it's ten past midnight here...).

>> As far as combining different drawings into one goes: Are you aware of the QCAD command line tool 'merge'?
This command line tool merges different drawing files into one, based on an XML input file.<<

No, I did not noticed it. Thanks for the info. Merge seems to be an interesting tool and I will try it.

>> If I understand your task at hand correctly, this might be a good starting point. The merge tool is entirely implemented in ECMAScript under scripts/Tools/MergeDrawings/MergeDrawings.js<<

This is even more interesting. Code examples are often the best way to learn a programming technique.

Thanks again for your help.

alexbottoni
Newbie Member
Posts: 9
Joined: Wed Nov 26, 2014 5:21 pm

Re: How can I ensure that a path is uninterrupted?

Post by alexbottoni » Thu Nov 27, 2014 9:54 am

I'm back with an example. Please refer to the attached image.
example-of-assembly.jpg
example of assembly
example-of-assembly.jpg (18.7 KiB) Viewed 14203 times
As you can see, I have a base drawing and a couple of modular blocks. I have to assemble (concatenate) them as pictured. The final drawing will be sent to a laser cutter. The entire drawing will be cut off from a sheet of metal. Ne etching involved.

The problem is: how can I perform such an assembly/concatenation operation from code in a dependable way? No manual tweaking or optimization can be performed here (because of the large amount of drawings we have to generate) and, of course, we must send a "safe" and manageable drawing to the laser cutter (no manual check and fix is possible, either).

As long as I understand, I cannot have gaps between the elements of the chain. I must have a continuous, uninterrupted path (a closed one, moreover). This creates some problem of dependability during the assembly operation.

I can link the base and the two other elements together in the points 1 and 2 using a snap (to the end of a line) but I cannot use this same technique with point 3 (because both ends of this link are already fixed/constrained). I would need a "smart join" tool for this.

Any suggestion?

User avatar
Clive
Moderator
Posts: 1329
Joined: Thu Aug 25, 2011 9:28 pm
Location: UK

Re: How can I ensure that a path is uninterrupted?

Post by Clive » Thu Nov 27, 2014 12:28 pm

alexbottoni wrote: but I cannot use this same technique with point 3 (because both ends of this link are already fixed/constrained). I would need a "smart join" tool for this.
After snapping points 1 and 2 point 3 presumably would be aligned correctly also - if so you could finalise by using the create polyline from segments command - Draw > Polyline > Create from Segments (O,G), this would create a continuous polyline.
For the best support please state your operating system, QCAD version and add any supporting DXF/DWG files, screenshots etc...

alexbottoni
Newbie Member
Posts: 9
Joined: Wed Nov 26, 2014 5:21 pm

Re: How can I ensure that a path is uninterrupted?

Post by alexbottoni » Thu Nov 27, 2014 4:08 pm

Clive wrote:After snapping points 1 and 2 point 3 presumably would be aligned correctly also - if so you could finalise by using the create polyline from segments command - Draw > Polyline > Create from Segments (O,G), this would create a continuous polyline.
Well, I cannot be sure that the two ends on point 3 will be correctly aligned. As a matter of fact, they will rarely be (because of a long sequence of small dimensional errors in the modular blocks that sum up to a not-irrelevant alignement error in the final drawing). Actually, this is the main source of my problems.

"Create from segments" do creates a polyline from a uninterrupted sequence (chain) of arcs and lines but it just stops when it finds the first gap (even a small one). It does not recognise the gap as an unwanted gap, does not inform you of its existence and does not try to fill it (with ad additional line/arc or by extending/trimming one of the existent elements).

I'm almost sure I can guarantee an uninterrupted path to point 3 (using a snap) but I still cannot see a programmatic way to detect the gap that could exist on point 3 (or in any other point of the chain) and fill it.

Anyway, I will try to use this procedure:
example-of-assembly-and-filling.jpg
example of assembly and filling
example-of-assembly-and-filling.jpg (16.77 KiB) Viewed 14166 times
That is:
  • 1) Create your chain, leaving a large, fixed and predictable gap at the end of the chain
    2) Always fill the gap with a custom-tailored line/arc (using the snaps)
    3) Create a polyline from the segments
Even if this technique cannot be used to detect a possible (hidden and unwanted) gap in the middle of the chain and/or fill it, it should allow me to go ahead with my specific case.

Thanks for your help.

User avatar
Clive
Moderator
Posts: 1329
Joined: Thu Aug 25, 2011 9:28 pm
Location: UK

Re: How can I ensure that a path is uninterrupted?

Post by Clive » Thu Nov 27, 2014 4:18 pm

alexbottoni wrote:"Create from segments" do creates a polyline from a uninterrupted sequence (chain) of arcs and lines but it just stops when it finds the first gap (even a small one). It does not recognise the gap as an unwanted gap, does not inform you of its existence and does not try to fill it (with ad additional line/arc or by extending/trimming one of the existent elements).
That's the key to this , we need additional options for the 'Create Polyline from Segments' tool - to:

1.Detect and show gaps in whole of selection.
2.Offer to fill with an optional entity - line,arc etc...

Hey Andrew, is this doable, certainly would be useful for a whole range of jobs?
For the best support please state your operating system, QCAD version and add any supporting DXF/DWG files, screenshots etc...

User avatar
Clive
Moderator
Posts: 1329
Joined: Thu Aug 25, 2011 9:28 pm
Location: UK

Re: How can I ensure that a path is uninterrupted?

Post by Clive » Thu Nov 27, 2014 4:30 pm

or actually ... just a brand new tool as you have already suggested - a 'Smart Join tool'
1. Make selction.
2.use 'smart join' tool and tool offers to find and fill all gaps :wink: .
For the best support please state your operating system, QCAD version and add any supporting DXF/DWG files, screenshots etc...

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

Re: How can I ensure that a path is uninterrupted?

Post by andrew » Thu Nov 27, 2014 6:13 pm

alexbottoni wrote:"Create from segments" do creates a polyline from a uninterrupted sequence (chain) of arcs and lines but it just stops when it finds the first gap (even a small one). It does not recognise the gap as an unwanted gap, does not inform you of its existence and does not try to fill it (with ad additional line/arc or by extending/trimming one of the existent elements).
Did you try adjusting the tolerance value?
Screen Shot 2014-11-27 at 18.03.12.png
Screen Shot 2014-11-27 at 18.03.12.png (16.94 KiB) Viewed 14150 times
Create from segments does not stop at any 'small' gap. It stops at a gap that is greater than the entered tolerance value.

If your blocks are reasonably precise, you can concatenate thousands of them and still end up with only a marginal error. A tolerance value of 0.001 should be plenty to account for that.

I wouldn't generally worry too much about precision. There's always an error (computers cannot represent all numbers precisely). But these errors are usually marginal enough to be ignored (<0.000001 drawing units).

Having said that, it is generally better to code algorithms in such a way that errors do not accumulate. I.e. calculating the absolute theoretical position of your blocks and inserting them at that position instead of basing the position on an existing end point might be a better option.

alexbottoni
Newbie Member
Posts: 9
Joined: Wed Nov 26, 2014 5:21 pm

Re: How can I ensure that a path is uninterrupted?

Post by alexbottoni » Thu Nov 27, 2014 6:19 pm

Clive wrote:or actually ... just a brand new tool as you have already suggested - a 'Smart Join tool'
1. Make selction.
2.use 'smart join' tool and tool offers to find and fill all gaps :wink: .
I do not think to be good enough at graphics programming for such a task. The main problem is: how could I detect the gap (in code)?

I will try anyway... :-)

BTW: A tool like that actually existed in a 3D CAD system I had the opportunity to use 10 or 15 years ago (more info available on request). Maybe some other high-end system have it as well.

User avatar
Clive
Moderator
Posts: 1329
Joined: Thu Aug 25, 2011 9:28 pm
Location: UK

Re: How can I ensure that a path is uninterrupted?

Post by Clive » Thu Nov 27, 2014 8:41 pm

Please refer to Andrews last post, it may be an option for you.
For the best support please state your operating system, QCAD version and add any supporting DXF/DWG files, screenshots etc...

alexbottoni
Newbie Member
Posts: 9
Joined: Wed Nov 26, 2014 5:21 pm

Re: How can I ensure that a path is uninterrupted?

Post by alexbottoni » Thu Nov 27, 2014 9:13 pm

andrew wrote: Did you try adjusting the tolerance value?
Ah, wonderful! I will try this way. It can even be a way to implement a (semi)automatic "smart join" in ECMAScript (as Clive suggested).

Thanks for your help, Andrew.

Post Reply

Return to “QCAD 'How Do I' Questions”