How to convert a set of strokes to a single bezier line?

Post questions on how to use or achieve an effect in Inkscape.
User avatar
[email protected]
Posts: 9
Joined: Tue Jul 05, 2016 6:30 am

How to convert a set of strokes to a single bezier line?

Postby [email protected] » Mon Aug 22, 2016 10:41 am

I'm using a Gear generator tool to draw a rack gear which I then plan to mill on my CNC machine. The Gear generator tool outputs the rack as an SVG file which I can open in Inkscape. For some reason the rack is made up of individual strokes (I assume they are strokes) overlapping but unconnected.

rack1.JPG
rack1.JPG (12.82 KiB) Viewed 2816 times


(I can't use the Inkscape gear extension because I can't define a matching circular gear and rack gear – don't ask me why).

I need to convert those strokes to a single connected bezier line.

I tried Path > Stroke To Path but that converts each stroke to a rectangle, defined by 4 nodes.

rack2.JPG
rack2.JPG (19.67 KiB) Viewed 2816 times


I can select all of those rectangles and connect them using Path > Union.

The problem is that the result is not a single bezier line, but an object with width. This means when I try to generate the CNC gcode I get a cut being made on each side of the rack, not on the outside only:

rack3.jpg
rack3.jpg (32.27 KiB) Viewed 2816 times


Can anyone suggest a method for getting from a series of unconnected but overlapping strokes, to a single bezier line with two end nodes?

Thanks!
Steve - Shapeoko 3; Inkscape, MakerCAM, UGS, bCNC.
Software engineer professional; woodworker journeyman; CNC tyro;

Moini
Posts: 3381
Joined: Mon Oct 05, 2015 10:44 am

Re: How to convert a set of strokes to a single bezier line?

Postby Moini » Mon Aug 22, 2016 10:53 am

You can use the node tool to connect two nodes:
- Select both objects (holding Shift)
- switch to node tool
- select both nodes (holding Shift)
- click on 'Join selected nodes' button in the node tool's tool bar at the top.
Something doesn't work? - Keeping an eye on the status bar can save you a lot of time!

Inkscape FAQ - Learning Resources - Website with tutorials (German and English)

Moini
Posts: 3381
Joined: Mon Oct 05, 2015 10:44 am

Re: How to convert a set of strokes to a single bezier line?

Postby Moini » Mon Aug 22, 2016 10:55 am

(You can also try if it works out correctly if you select all objects, then switch to node tool, select all nodes (Ctrl+A), then use the 'Join selected nodes' button - that's a bit faster ;-) )
Something doesn't work? - Keeping an eye on the status bar can save you a lot of time!

Inkscape FAQ - Learning Resources - Website with tutorials (German and English)

User avatar
[email protected]
Posts: 9
Joined: Tue Jul 05, 2016 6:30 am

Re: How to convert a set of strokes to a single bezier line?

Postby [email protected] » Tue Aug 23, 2016 4:10 am

Thanks for the reply, Moini.

Unfortunately, that doesn't work. I know about using the node tool to connect nodes - either by adding a segment or replacing two nodes with one. In this cases, however, each individual segment is made up of 4 nodes - like a rectangle. I can select a node on one segment corner, and select another node on an adjacent segment corner. Inkscape refuses to connect them.

Look at it this way. Segment 1 is defined by nodes A,B,C,D. Segment 2 is defined by nodes E,F,G,H. I'm trying to connect node A to E. If successful, node A is now connected to E, B, & D. My understanding of bezier lines (possibly mistaken) is that each node can have at most two connections to other nodes. In this case I'd be trying to connect a third node, and I don't think that is allowed.

rack4.JPG
rack4.JPG (85.55 KiB) Viewed 2751 times
Steve - Shapeoko 3; Inkscape, MakerCAM, UGS, bCNC.
Software engineer professional; woodworker journeyman; CNC tyro;

User avatar
Maestral
Posts: 982
Joined: Sat Aug 27, 2011 7:10 am

Re: How to convert a set of strokes to a single bezier line?

Postby Maestral » Tue Aug 23, 2016 4:33 am

I believe the most answers you`re looking for are described in this part of the Manual.

Also, some interesting stuff might pop-up if you use centerline tracing as a key words for a web search.
:tool_zoom: <<< click! - but, those with a cheaper tickets should go this way >>> :!:

Moini
Posts: 3381
Joined: Mon Oct 05, 2015 10:44 am

Re: How to convert a set of strokes to a single bezier line?

Postby Moini » Tue Aug 23, 2016 6:59 am

Don't convert stroke to path before you try using the method I described.
Something doesn't work? - Keeping an eye on the status bar can save you a lot of time!

Inkscape FAQ - Learning Resources - Website with tutorials (German and English)

User avatar
[email protected]
Posts: 9
Joined: Tue Jul 05, 2016 6:30 am

Re: How to convert a set of strokes to a single bezier line?

Postby [email protected] » Tue Aug 23, 2016 3:24 pm

Maestral -- thanks -- I read that section and it cleared up some of my confusion -- especially the difference between Object to Path and Stroke To Path. Centerline tracing may be the way to go, but I'm still hoping for an Inkscape solution.

Moini -- thanks also. When I import the original set of lines that form the rack, they show up as objects only. They do not have nodes. They really don't. The only way to get them to have nodes is to apply Object to Path. (I understand now Stroke to Path is a dead end).

Now I'm trying to apply your suggestion. I select the two end nodes on the two segments I want to join:

rack2_1.JPG
rack2_1.JPG (15.6 KiB) Viewed 2705 times


And then I apply "Join selected end nodes with a new segment". But I get this:

rack2_2.JPG
rack2_2.JPG (16.04 KiB) Viewed 2705 times


Not what I want. (Incidentally, if I draw two Bezier lines from scratch and apply the "Join" operation, everything works as expected; a new segment shows up joining the endpoints).

So I'm guessing these imported objects, whatever they are after I apply Object To path, are not standard Bezier lines. In fact, when I select one of the lines, I get a statement that I can drag it to make it a Bezier line. If I do that (of course destroying the position of the segment which is the whole freaking point of this exercise) -- THEN I can join the segments normally.

rack2_3.JPG
rack2_3.JPG (33.43 KiB) Viewed 2705 times


So is there some way to convert this "linear segment" (whatever the heck that is), to a Bezier line, without actually dragging the line?

Thanks for helping a noobie out. I really appreciate it. :D
Steve - Shapeoko 3; Inkscape, MakerCAM, UGS, bCNC.
Software engineer professional; woodworker journeyman; CNC tyro;

User avatar
Maestral
Posts: 982
Joined: Sat Aug 27, 2011 7:10 am

Re: How to convert a set of strokes to a single bezier line?

Postby Maestral » Tue Aug 23, 2016 5:34 pm

rack2_2
You have fill enabled for that shape, that`s why it looks that way. Please, check the Manual for more info.

rack2_3
I can`t get that line on my status bar but, Bezier is more often a curve rather than a straight line. I`d try with another Ctrl+Shift+C to convert it to the path - or - if you need that segment to have some curvature, select the desired node/s and change their curvature from the top menu bar. (again, Manual, please .. ,)

Rock on and chime back if you stumble.
Last edited by Maestral on Tue Aug 23, 2016 9:34 pm, edited 2 times in total.
:tool_zoom: <<< click! - but, those with a cheaper tickets should go this way >>> :!:

Moini
Posts: 3381
Joined: Mon Oct 05, 2015 10:44 am

Re: How to convert a set of strokes to a single bezier line?

Postby Moini » Tue Aug 23, 2016 7:11 pm

If you don't want the additional segment inserted, try 'Join selected nodes', not "Join selected end nodes with a new segment".
As Maestral says, Object to Path is fine, you only need to remove the fill.
Something doesn't work? - Keeping an eye on the status bar can save you a lot of time!

Inkscape FAQ - Learning Resources - Website with tutorials (German and English)

User avatar
[email protected]
Posts: 9
Joined: Tue Jul 05, 2016 6:30 am

Re: SOLVED -How to convert a set of strokes to a single bezier line?

Postby [email protected] » Wed Aug 24, 2016 12:52 pm

Maestral -- I had never come across a Bezier line with the fill turned on and didn't even realize it was possible. It's a dimensionless line, for crying out loud. But that was a big source of my confusion. I promise to read the manual first next time.

Moini - your suggestions finally penetrated. The process is:

    Select all lines
    Path > Object to path
    Select all paths
    Switch to node editor (F2)
    Deselect end points; leave rest selected
    Join selected nodes
    Turn fill off

This results in what I want -- a single Bezier line with two endpoints forming the outine of the rack gear.

Thanks for all the help! :D
Steve - Shapeoko 3; Inkscape, MakerCAM, UGS, bCNC.
Software engineer professional; woodworker journeyman; CNC tyro;

User avatar
Maestral
Posts: 982
Joined: Sat Aug 27, 2011 7:10 am

Re: How to convert a set of strokes to a single bezier line?

Postby Maestral » Wed Aug 24, 2016 5:22 pm

Just to make it clear, as much as possible...

To draw a line, you use Pen or some other tool. As in math, a line is defined by two points - so, no room for fill there. But, from the tool`s POV, you are creating a shape which makes room for the fill.

In the Preferences, you may set the "default" behaviour of each tool or to let it keep last used settings (color, no color, width...)
:tool_zoom: <<< click! - but, those with a cheaper tickets should go this way >>> :!:

Moini
Posts: 3381
Joined: Mon Oct 05, 2015 10:44 am

Re: How to convert a set of strokes to a single bezier line?

Postby Moini » Wed Aug 24, 2016 10:02 pm

@[email protected] : Will you send us a picture of your final result? We're always curious to see what comes out of our forum help :)
Something doesn't work? - Keeping an eye on the status bar can save you a lot of time!

Inkscape FAQ - Learning Resources - Website with tutorials (German and English)

User avatar
[email protected]
Posts: 9
Joined: Tue Jul 05, 2016 6:30 am

Re: How to convert a set of strokes to a single bezier line?

Postby [email protected] » Sat Aug 27, 2016 4:33 am

Surely!

Still a ways to go before I start milling gears, but I'll send a long a few images when I get there.
Steve - Shapeoko 3; Inkscape, MakerCAM, UGS, bCNC.
Software engineer professional; woodworker journeyman; CNC tyro;


Return to “Help with using Inkscape”