ISO autoadjust of some sort so I can join polylines or splines w tiny gaps

ISO autoadjust of some sort so I can join polylines or splines w tiny gaps

jetted4
Advocate Advocate
3,919 Views
24 Replies
Message 1 of 25

ISO autoadjust of some sort so I can join polylines or splines w tiny gaps

jetted4
Advocate
Advocate

So sometimes at work we get client DWG files that were computer generated and need to be cleaned up before use.   Not uncommonly, instead of a nice fluid spline or polyline, the drawings are made up of a ton of tiny segments that don't quite meet each other so the join command doesn't work.

 

It's a pain to try to modify the drawings with hundreds of tiny lines and it takes forever to join them all.

Is there any option or command or lsp program that would autoadjust the positioning of the line/spline segments so that they meet end to end so that the join command will work?

(the gap between them is so small it wouldn't make a difference which segment got moved in terms of the drawing appearance)

 

Thanks  🙂

0 Likes
3,920 Views
24 Replies
Replies (24)
Message 2 of 25

Patchy
Mentor
Mentor

Is there any option or command?

PEDIT, Multiple, Join with Fuzz distance already built in.

0 Likes
Message 3 of 25

jetted4
Advocate
Advocate

Thanks  🙂

Is there something that will work for splines? Or do I have to turn them into polylines and then use the same process?  Unfortunately, when I've tried converting splines to polylines, the number of segments is very high, so I am hoping to be able to join the splines to splines and polylines to splines as is with some fuzz allowance for both.

 

0 Likes
Message 4 of 25

ChicagoLooper
Mentor
Mentor

There's a command for this. Use MAPCLEAN with the option to 'Extend Undershoots.'

 

20-cleanup actions.JPG

 

 

You can also read about UNDERSHOOTS here.

 

30-extend undershoots.JPG

Chicagolooper

EESignature

Message 5 of 25

Patchy
Mentor
Mentor

It's not possible to join spline to polyline, if too many vertices after converting spline to polyline, run this autolisp, then join them.

https://cadtips.cadalyst.com/linear-objects/polyline-diet?q=linear-objects/polyline-diet

0 Likes
Message 6 of 25

jetted4
Advocate
Advocate

Thanks to both of the above suggestions...I will give them a try  🙂

0 Likes
Message 7 of 25

jetted4
Advocate
Advocate

Unfortunately, I am not having success so far...

The pedit/multiple/join with fuzz distance works great with polyline segments, which is good.  🙂

However, I am still stuck when part of the geometry is splines...or if some of it is elliptical arcs since when they join to polylines it turns into a spline.

 

For joining splines when there is a tiny gap in between them:

Mapclean is apparently not available in core Autocad.

 

I tried converting the splines to polylines and then setting a fuzz distance to join them.  It did join them all successfully, but I ended up with a crazy high number of polyline segments in order to maintain the curvature of my original splines.

 

I then tried using the PLD lsp program from the above link to reduce the number of vertices.  It did successfully reduce the number, but the problem with the PLD lsp command is that, same as with REBUILD (not sure how REBUILD and PLD lsp command differ...), the side effect of reducing the number of polyline segments is that I get a jerkiness to what used to be a smooth curve (see attached).

 

So unfortunately, it doesn't seem as if I can convert splines to polylines in order to use the <join/fuzz distance> approach if I need to maintain the original shape.  Any ideas on how else to ask for a fuzz distance when part of my geometry is splines?

 

Thanks  🙂

0 Likes
Message 8 of 25

Alfred.NESWADBA
Consultant
Consultant

Hi,

 

joining splines and polylines means you have to decide if the resulting object should be a spline or a polyline, you can't have spline-functionality on some segments of the new object and polylines on the other segments.

 

Converting splines to polylines create a lot of vertices, yes, and you lose the spline functionality, however you can join with tolerance values.

Keeping splines and their functionality means you need to convert the polylines to splines to be able to connect them together, however there does not exist a cleaning option with fuzzy tolerance ... because it could get tricky to move a vertex without losing the tangent information for this vertex (or at least hold it in a way it works well on the new vertex position).

 

So the questions I have at first ... how many vertices needs to be cleaned, how often do you need this, what's the size of the geometry and the size of the fuzzy tolerance.

And if you have a file so we can see what you have could help too.

 

- alfred -

------------------------------------------------------------------------------------
Alfred NESWADBA
ISH-Solutions GmbH / Ingenieur Studio HOLLAUS
www.ish-solutions.at ... blog.ish-solutions.at ... LinkedIn ... CDay 2026
------------------------------------------------------------------------------------

(not an Autodesk consultant)
0 Likes
Message 9 of 25

leeminardi
Mentor
Mentor

You can also look into using the Civil 3D weed function on the polyline that has too many vertices.  It keeps more vertices in section with tight curvature and fewer where the curvature is slight.

lee.minardi
0 Likes
Message 10 of 25

jetted4
Advocate
Advocate

Thanks  🙂

I wish I had a good real-life example to show that matches the design complexity but the drawings I work with are usually proprietary and are as yet unreleased designs.

 

But I attached a simple example for trying to join two curves (one is a spline and the other a polyline) with a gap of only .0002 between them.  I used pedit to convert the spline to a polyline so that I can use the fuzz distance to join them.  With a precision = 2,  the result has many obvious points in the resulting polyline which won't work for our purposes.  I hand created a polyline overlay for my original spline and was able to match the number of vertices from the precision=2 pedit conversion, yet my hand drawn one maintained the smoothness of the curve that is necessary for my work projects.  But it takes time to redraw everything.  Upping the pedit precision to 10, though much smoother and probably good enough in appearance, has way too many points for needing to make modifications to a drawing without undue time invested.

 

I often need to clean up a digitally created drawing but it takes too much time to find tiny gaps when they exist (which is rather frequent when we make cross sections and take flatshots of objects...especially when the original 3d model was digitally created.) Many times I need to hatch an area to represent the type of material it is made from.

 

Sometimes hatching an area within a series of unjoined pieces will work, but sometimes it bleeds so I have to either redraw the shape or find all of the broken points and attach them before joining in order to get the hatch to work.

 

Other tasks require just trying to tweak the shape to demonstrate a change under pressure (for example), that is still a pain when you've got a bunch of small computer generated individual lines and arcs, so I want to quickly select them all and join them so that changing the shape (or transforming the area in any other way) is less time consuming.

 

I am fine with polylines being converted into splines when they join with elliptical arcs or pre-existing splines, I just wish the fuzz distance could work for splines.

 

Comparison:

When I converted a polyline with 3 vertices into a spline, it resulted in 9 vertices (3 times the original number).  Not ideal but manageable.  However, I cannot then join individual splines together if there is no such thing as a fuzz distance for splines.

 

But when I did the reverse and created a polyline from a spline (with precision of 10 so that the shape was fairly well maintained), my 4 spline vertices were converted into 24 polyline ones (6 times the original number).  That's too many vertices to make any amount of editing/transforming of the shape practical.

 

With the gaps between the individual lines being so small, Autocad just needs to move the end point of one line/spline/polyline to touch the end point of the other with no new vertices being needed (or wanted, for that matter) ...the pieces are so close  together that the original shape will be  maintained -  and then I can join them together for ease of any future changes/edits.

0 Likes
Message 11 of 25

ВeekeeCZ
Consultant
Consultant

Try to use FLATTEN to convert SPLINE to PLINE. IMHO you'll get better results.

Also, when connecting ents using fuss also try to use MPEDIT with its add option... There were some issues with this option on built-in PEDIT version.

0 Likes
Message 12 of 25

jetted4
Advocate
Advocate

Thanks  🙂

I will look into both of them  🙂

0 Likes
Message 13 of 25

leeminardi
Mentor
Mentor

Also check out PLDIET (post #17 here).  YOu can use it to weed excessive vertices from a polyline (no need for Civil 3D).

 

Here are some examples of using PLDIET with different values for maximum distance and angle.  Note, the images you attached would not display for me. I found it easiest to click the camera icon and then a Ctrl-V to post images).

image.png

Here's a zoomed in view showing the difference between the original raw polyline of 310 vertices and the PLDIET version with 89.

image.png

lee.minardi
0 Likes
Message 14 of 25

jetted4
Advocate
Advocate

Thanks 🙂

I did a quick test of pldiet after my first post and it was changing the shape too much, but I didn't really have a good feel for what parameters to use...I'll test it out some more using your example as a springboard.  

 

Take care,

Andrea

0 Likes
Message 15 of 25

ChicagoLooper
Mentor
Mentor

@jetted4 wrote:

.......Is there any option or command or lsp program that would autoadjust the positioning of the line/spline segments so that they meet end to end so that the join command will work?

(the gap between them is so small it wouldn't make a difference which segment got moved in terms of the drawing appearance)........

 

.......Sometimes hatching an area within a series of unjoined pieces will work, but sometimes it bleeds so I have to either redraw the shape or find all of the broken points and attach them before joining in order to get the hatch to work......


You can do it. Try this.

 

Use HPGAPTOL on you hatch. So far, you’ve experimented with Spline-This-and-That and Polyline-This-and-That. What you haven’t tried, though, is investigated the hatch component of your opening post. Try using the HPGAPTOL variable which addresses the boundary, or more specifically, the gap on your hatch area.

 

You can set you gap tolerance in the System Variables dialog window. Simply go to Express Tools tab=>Tools panel=>System Variables button. The default value is 0 which means only ‘closed’ boundaries will accept hatch. See image-1.

 

Image-1.Image-1.

 

 

You can also set the gap tolerance in hatch settings. See image-2.

 

Image-2.Image-2.

 

 

The strange thing about the HPGAPTOL variable though, is its behavior. Sometimes it performs as expected while at other times it doesn’t. Too bad, although it’s a good way to hatch areas without having to mess around with closing the space in between lines its unexpected results make it somewhat difficult to work with. Here’s an exercise I performed to illustrate the whacky behavior.

 

EXPERIMENT 1:

I started with 4 polygons, each with identical dimensions and each with a gap measuring 2 drawing units wide. I set the HPGAPTOL to 3.0 which is greater than the actual gap. I then hatched each polygon using a different hatch pattern. Using the SELECT POINTS option of the HATCH command, the 2.0 gap was ignored and the polygon was hatched as expected. See image-3.

 

Image-3.Image-3.

 

 

EXPERIMENT 2:

I repeated the experiment but this time using SELECT OBJECTS option to hatch each polygon. This time the results varied. All hatch patterns ANSI31, Earth and Hex were whacky, each had ‘missing lines’ while the Solid pattern didn’t hatch at all. See image-4.

 

Image-4.Image-4.

 

 

Next I drew four new, or two pairs, of boundaries: spline & spline and polyline & spline to ascertain the effects of HPGAPTOL on boundaries other than a ‘broken polygon.’ Dimensions of the four gaps are shown below. See image-5.

 

Image-5.Image-5.

 

 

EXPERIMENT 3:

I kept the HPGAPTOL=3.0, again a value greater than the actual gap. All hatch failed at 3.0 tolerance. I then decreased the tolerance to 0.6 which is still greater than the dimensioned gaps. At 0.6 tolerance, only the polyline & spline boundary produced a hatch while spline & spline boundary did not. Next, I increased the tolerance from 0.6 to 1.0. Surprisingly, the 1.0 tolerance produced hatch on both pairs of boundaries albeit with whacky results. See image-6.

 

Image-6.Image-6.

 

 

For spline & spline boundary only ANSI31 honored the boundary while Earth, Hex and Solid extended their pattern beyond the spline & spline.

For polygon & spline boundary, all 4 patterns honored the boundary. Two patterns, earth and hex, had incomplete patterns (lines within their pattern were missing).

 

CONCLUSION:

Using HPGAPTOL may (or may not) give you a hatch pattern without manipulating the geometry of your original line work, if and only if, you use the right hatch pattern at the right gap tolerance. Finding the gap sweet spot, or a tolerance value that’s not too small and not too large will solve your problem, not finding a way to marry a spline with a polyline to close the gap.

Chicagolooper

EESignature

0 Likes
Message 16 of 25

jetted4
Advocate
Advocate

Thanks for the hatch info  🙂

I had tried setting a tolerance larger than my gaps once and it hadn't helped, but I hadn't tested it so much as this so I definitely appreciate the research  🙂

 

I still would love to solve the fuzz distance issue since modifying something made up of a bunch of small splines and lines (as I had mentioned as being the other part of my challenge) is a pain, but the hatch info at least tackles part of the problem areas.

 

Thanks 🙂

0 Likes
Message 17 of 25

jetted4
Advocate
Advocate

Well, for setting the HPGAPTOL as a way to try to hatch an area without having to join all of the splines/lines/polylines that have tiny gaps between then, I am falling into the "may not" category as to whether it will help.

 

I attached a sample dwg file containing a rubber component from an electronics device.  The drawing is a flat shot of a cross section of a 3d model that was imported into Autocad from an STP file. (a typical scenario for us).

 

I set the HPGAPTOL to .0005

(when I measured one of my gaps, which was a typical size, it measured 0.0000).

Unfortunately, I am getting bleed in one section of the hatched area.

 

The hatch scale and pattern are necessary for our client procedures so I don't really have the option of finding a different one that works better with the tolerance setting...

0 Likes
Message 18 of 25

Alfred.NESWADBA
Consultant
Consultant

Hi,

 

at the position with the red arrow you have 2 splines and not just one.

Both are not long enough to be joined with the object that starts at the right end...

 

20200203_163456_0001.png

 

If you delete one of the splines  and then use command _STRETCH to move the endpoint (using object snap _ENDpoint) of the left spline to the startpoint of the right spline you will be able to join them.

 

- alfred -

------------------------------------------------------------------------------------
Alfred NESWADBA
ISH-Solutions GmbH / Ingenieur Studio HOLLAUS
www.ish-solutions.at ... blog.ish-solutions.at ... LinkedIn ... CDay 2026
------------------------------------------------------------------------------------

(not an Autodesk consultant)
0 Likes
Message 19 of 25

ChicagoLooper
Mentor
Mentor

I was able to do this.......

400-sttings&hatchedarea.png

 

Were you able to get as far as the image shown above?

Chicagolooper

EESignature

0 Likes
Message 20 of 25

ВeekeeCZ
Consultant
Consultant

Try THIS  routine. It just marks the gaps with circles. Then try manually connect marked ends with a line/pline. Then use some.... whatever tool to join it.

If this works for you... we'll see if the routine could be adjusted... someway sensibly.

0 Likes