Removal of overlapping lines or stacked lines of different lengths

Drop in here to discuss whatever you want.

Moderator: andrew

Forum rules

Always indicate your operating system and QCAD version.

Attach drawing files and screenshots.

Post one question per topic.

Post Reply
John Hyslop
Premier Member
Posts: 472
Joined: Mon Sep 30, 2019 6:21 am
Location: Melbourne - Australia

Removal of overlapping lines or stacked lines of different lengths

Post by John Hyslop » Sat Dec 14, 2019 4:37 am

Hi Andrew
I know qcad has some clean up tools to remove duplicate lines and zero length lines..how hard would it be to implement the following..
1: remove stacked lines and arcs of different lengths and leave the longest length as 1 line or arc?
2: join connected or overlapping lines that could be drawn as 1 line.? ( and arcs also )

I can remove entities as described above by creating a polyline say of a perimeter then moving the polyline and deleting the left over segments..

I sometimes have to go through this process if someone has supplied a file to me to clean up for laser cutting...

Just some food for thought...

Cheers
John
PS by stacked I mean entities laying on top of each other of varying lengths...hope this makes sense..
IF IT IS TO BE IT IS UP TO ME [ Ten most powerful 2 letter words ]

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

Re: Removal of overlapping lines or stacked lines of different lengths

Post by CVH » Sat Dec 14, 2019 9:36 am

John,
Indeed: knowing what the customer wants is one.
Cleaning out the crab is usually the next hurdle.
Gave it many thoughts tough. :|
Instead I have a certain workflow and it will take time.

1)
It is something many look for in 'Detect Duplicates'.
It will not find stacked lines of different lengths, interconnected or not.
'Detect Zero' or detect 'Z..short' can help when you have an idea of what is the meaningful shortest.
In such a process I usually don't delete but set aside.
Quite dangerous to let the soft decided what to trow away.
A very clever heuristic routine is needed to find out what is meaningful.
My use is mostly artistic, yours probably sheet metal.

But I'll vote for this! :P

2)
Again, not that obvious to let the soft decided what to keep.
For this I 'mis'-use the difference of:
> OG find connected strings of segments to poly.
This doesn't join any segments, it only concatenate them.
> OC poly from selection of my choise.
This can join some segments (but also can add connecters).
Together with a appropiate steep tolerance, temporary layers, OS, ON and Explode.
After some cleaning leftovers one has his goal.

When such a function would create a best matching clone,
and not alter the source in one go. I'll vote for this. :P

Regards,
CVH
Last edited by CVH on Wed Jun 24, 2020 8:07 am, edited 3 times in total.

John Hyslop
Premier Member
Posts: 472
Joined: Mon Sep 30, 2019 6:21 am
Location: Melbourne - Australia

Re: Removal of overlapping lines or stacked lines of different lengths

Post by John Hyslop » Sat Dec 14, 2019 9:44 am

Hi CVH

Thanks for your support on this one :-)
Laser machines don't like stacked lines it's tends to cut over the profile 2 or 3 or howmany times when
the lines are stacked... my clients software cannot detect this so I guess I can be happy I get work:-)
Agree with you 100% this would be a very hard add-on to make... loads of calculations and yes you are
correct how would it know what ones to keep and discard...

Oh bye the way love the new Property Painter Tool... Great work :-)

Cheers
John
IF IT IS TO BE IT IS UP TO ME [ Ten most powerful 2 letter words ]

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

Re: Removal of overlapping lines or stacked lines of different lengths

Post by CVH » Sat Dec 14, 2019 9:58 am

Funny,
Flexpainter is mine.

For Property painter all the credit is Andrew's.
Cheers

John Hyslop
Premier Member
Posts: 472
Joined: Mon Sep 30, 2019 6:21 am
Location: Melbourne - Australia

Re: Removal of overlapping lines or stacked lines of different lengths

Post by John Hyslop » Sat Dec 14, 2019 10:04 am

Oops ...nice work Andrew...
I'll check yours out tomorrow CVH 👌
Cheers
John
PS couldn't wait to look CVH had a little look and
WOW..so many things you can do..I will need to have
a real look at all the options..very nice interface nice work as expected 👌
IF IT IS TO BE IT IS UP TO ME [ Ten most powerful 2 letter words ]

Brifu Atriedger
Registered Member
Posts: 1
Joined: Thu May 13, 2021 5:42 pm

Re: Removal of overlapping lines or stacked lines of different lengths

Post by Brifu Atriedger » Fri Jul 08, 2022 10:07 pm

Hello,

I hope it is not in bad form to revive such an old thread but I also could make heavy use of a feature that could do this. I program for waterjets and punch machines. Stacked entities are often (virtually always) troublesome and difficult to get to behave as needed. In this moment of desperation, I searched for this topic and found this post. I understand the concern over the decision of which entity to keep and those that get thrown away.

Given that a line or arc (or any entity for that matter) is defined by every point on that line (or entity) would it be possible programmatically to explode every entity into the points that it consists of and then toss all duplicate points leaving only one point each? Then would it be possible to reconnect and simplify all these points into lines/arcs/polylines?

Secondary question: Is a "zero-length" entity just another way of calling out a point? If not, what is a "zero-length" entity?

I do realize that for all but the simplest parts, this would involve untold zillions of points and surely it would take someone far smarter than I to get this working reliably. It takes me 3 tries or more to add 3+1 and come up with the correct answer of 5... :wink:

Thank you for considering this.
--
B~

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

Re: Removal of overlapping lines or stacked lines of different lengths

Post by CVH » Sat Jul 09, 2022 7:24 am

Brifu Atriedger wrote:
Fri Jul 08, 2022 10:07 pm
Given that a line or arc (or any entity for that matter) is defined by every point on that line (or entity) would it be possible programmatically to explode every entity into the points that it consists of and then toss all duplicate points leaving only one point each?
I think this is not a real solution.
A) Only for line segments.
B) It may add unnecessary nodes but these can indeed be simplified in the long run.
Remark here that OS won't simplify polyline arc segments but that OC & OL (only) may merge matching arcs. :wink:

Arcs don't really have endpoints, they have ending angles. e_geek
It may even be true that an endpoint of an arc cannot be expressed mathematically correct in the limited numerical system.
Even more problematic for (tangentially) connected arcs. :(
The uncertainty is much larger when positions are far away from the origin where the integer part gets longer and the fractional part shorter.

For one, a point has no dimension, no size. e_geek
Any length value divided by zero is infinite.
One cannot explode every segment in an infinite number of points.

The work-flow should consider endpoints and those that are on/near other entities.
But quickly we get back to what to keep and what to reject as result, while I am not the advocate to simply delete/trow away. :roll:

Then there is the question of tolerances.
- Which entities are exact or almost duplicates?
- What is partially overlapping? What if angled/misaligned?
- When are two entities considered to be connected?
- What is contiguous aka in-line?
- What entity to do/keep when the orientation is almost matching?
- Should we auto-trim in all cases?
(In fact, we should always trim segments pair-wise before even creating a polyline with OG, OC & OL :!: See my posts)

Then we come to the second question.
- Because a point has no size it is displayed as in the Drawing Preferences .. Point Display.
- A zero-length entity is displayed as a blob in its actual lineweight.

Zero-length entities are usually the result of (erroneous :wink: ) trimming.
E.g. trimming an arc 45-180° all beyond 45° leaves an arc starting at 45° but also ending there.
The center and radius will still hold, sweep would be 0° and the length is thus zero.

But you can actually create them: Line from 2 Points (LI), indicate twice the same spot, Escape (QQ).

One can only select these by a box, not individually. MZ will find them.
I would say that this should be avoided but there are pro and cons about casting Zero-length entities.

There are also Null-entities, after reloading a drawing these would be allocated at the origin.
Fundamental shapes with incomplete data. IMHO it is wrong to cast them on a drawing.


If time permits, I will look (again) deeper in this. 8)
But I am afraid that I will end up with tool like 'RoundPolylineCorners' that John Hyslop knows among some.
Circumventing many problems/errors but just impossible for all. :oops:
What requires human intervention at some point and also the main reason why that tool is not released. :(


Regards,
CVH

Post Reply

Return to “Chat”