1

I am working with a pattern making software that exports to a PDF. I cannot control the output vectors. When I open this file, the file in Illustrator has a million short line segments that are all straight lines.

enter image description here

I have tried joining them. I also tried using the script Join Reasonably. Both have about the same result. If I kept the line black, that wouldn't be a problem, but when I give the line a special brush, I get this:

enter image description here

Is there a script or extension I can use to either turn an area of my shape into a smooth curve with handles and maybe only one or two anchor points? If there isn't, is it possible a script can be created to do this?

What I currently do is just use the existing shape as a guide and redraw the shape over it with a new layer. It is very time consuming when I'm dealing with 500+ of these at a time. Any advice? Thanks in advance.

1
  • Please, check if your line segments are actually narrow closed loops. They need totally other treatment than line segments. You get closed loops easily if you vectorize scanned drawings which have dashed lines.
    – user82991
    Dec 7, 2018 at 2:47

3 Answers 3

1

The problem is an old one. The old answer is "use Object > Path > Simplify and set the tolerances as tight as you need, join the lines at first, if they are separate"

I suggest try Inkscape. It also has Path > Simplify which reduces nodes, but I have found it respects long straight line segments more than Illustrator's simplify. See an example:

enter image description here

The black shape has only joined line segments. The red shape is the same after a few Path > Simplify commands (=Ctrl+L)

The blue shape has got one more Ctrl+L. Top left corner is rounded. Now it's the time to press Undo and delete manually still a few nodes with the node tool.

You can keep a locked original below to see if the result is still acceptable. It's done in the next image:

enter image description here

In Illustrator using Simplify needs a little more manual edits. You must convert those anchors which should stay sharp back to corner points and move them back to their right places. In addition, the handles of the nearest smooth anchors needs a little adjustment. Fortunately those tweaks are easy if you have a locked copy of the original below and snap to points =ON.

Totally other measures are needed, if your line segments are not lines, but separate narrow closed paths. You get them easily for ex. vectorizing scanned drawings which have dashed lines. Then you can try to fill the interior with the Shape Builder or Live Paint Bucket.

A test example:

enter image description here

In the left there's a dashed stroke shape. The stroke width is 0,35mm It's outlined in the middle, there's no stroke to show it is separate closed loops.

Shape Builder cannot make a good shape from it. Gap detection doesn't help. The gaps will get filled randomly. The shape will be inaccurate. The gaps must be filled. One way to do it is to give thick enough stroke to the loop chain. It's done in the right.

The new stroke must be outlined again and the generated parts must be united in the pathfinder panel. That result can be treated ok with the shape builder. It is in use here:

enter image description here

The shape builder is set to give a green fill to show the result. In the next image the generated shape is without fill, only a green stroke. It's aligned with the loop chain:

enter image description here

We see that the new curve has offset about twice the width of the loop chain. Object > Path > Offset path > 0,7mm generates a new path which fits perfectly:

enter image description here

Now there's no problems with custom pattern brushes:

enter image description here

3
  • I looked closer and pulled a line segment out from the group and realized there are several points to each line segment. Dec 7, 2018 at 20:41
  • @JenniferFairbanks but are the segments closed shapes? Or something even more complex? Can you give a link to a real sample?
    – user82991
    Dec 7, 2018 at 20:45
  • I didn't think to edit my original post (I'm a newbie here), so I posted more as another answer. I think I can make it work unless you see something different. Dec 7, 2018 at 21:01
1

I just noticed that the line segments are more complicated than just a simple line segment. I pulled one line apart and notice each endpoint has 3 points.

enter image description here

I also noticed that the fill and outline are flipped from what a line normally is and when I switch it, this is what happens to the line.

enter image description here

Update: I tried simplifying multiple times and I get this new line, which is not very close to the first image. The new simplified line is in green.

enter image description here

Update: Ok- I think even though the lines aren't exact, they should be good enough for this. I'll have to test to make sure the shaped isn't changed too much when printing. These are sewing patterns, so there is a certain amount of preciseness that needs to remain.

enter image description here

2
  • Dont use answer section to add details edit your question.
    – joojaa
    Dec 8, 2018 at 13:19
  • also you can set precision to a 100% and the line will hit each point.
    – joojaa
    Dec 8, 2018 at 13:21
0

Select all the segments...

Command/Ctrl+J or Object > Path > Join.

You may need to do this twice depending upon how close together segments are. If there's a gap too great, paths may not join. However, a second tap of the shortcut should then join them.

After wards you can use Object > Path > Simplify to smooth things if needed.

enter image description here

(Ignore the F1 shortcut you see in the animation. That is merely my personal shortcut setting for the Simplify command and is not a default AI shortcut.)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.