Fill closed path made from disconnected segments[solved]

Post questions on how to use or achieve an effect in Inkscape.
guybrush
Posts: 2
Joined: Fri Mar 30, 2012 9:53 pm

Fill closed path made from disconnected segments[solved]

Postby guybrush » Fri Mar 30, 2012 10:24 pm

Hello everyone,

I am having the following issue: I am importing a dxf file in inkscape. The dxf file was created with the CAD software Solidworks. The file contains the outline of a part (in 2D), and therefore takes the form of a closed path. What I want to do appears simple, I want to fill the inside of the part and save it in a vector format (SVG or eps). So logically, all I need to do is to unset the stroke color, and set a fill color.
Too bad this is not that simple.
It turns out that the closed path in the DXF file is only "apparently" closed. It in facts consists of a collection of separate two nodes splines, and the end node of one segment coincides (has the same position) than the start node of the next segment. No wonder than I can not set a fill for the complete closed path.

I tried several things, but could not find an acceptable solution:

1) I tried to select all the separate segments and combine them using the menu "path->combine". Now I have a single path, but it still consists of separate segments. Then I had to manually go to each segment extremity, select the start/end nodes, and use the "join selected nodes" function. If I do that to all the segment, then I end up with a single closed segment that I can fill. However, this process is too much time consuming given the number of separate segments that must be joined together. What I would need is an automated way to join super-imposed nodes. Is it possible to do something like this?

2) I tried to use the "fill bounded area" tool but it comes with its own problems: -How close the filling comes to the border depends on the zoom level, which means that I have to zoom a lot if I want to have a filled area with shape and dimension very similar to the path that serves as boundary, and then I end up with may different filled area that I must now combine. -The filling stops at the inner border of the border path, which means that the size of the filled zone depends on the stroke width. Setting the stroke width to 0 does not work, as the complete work zone gets filled.

If you have any idea How I coud fill this zone which is formed by separate segments instead of a continuous single segment, please tell me!

Thanks in advance for your help!
Last edited by guybrush on Tue Apr 03, 2012 10:22 pm, edited 1 time in total.

User avatar
brynn
Posts: 10309
Joined: Wed Sep 26, 2007 4:34 pm
Location: western USA
Contact:

Re: Fill closed path made from disconnected segments(DXF imp

Postby brynn » Sat Mar 31, 2012 9:34 am

Image
Welcome to InkscapeForum!

I'm happy to say that there will be 2 ways to quickly resolve the problem using either of the methods you've discovered. (Lately I've seen a lot of problems which aren't as easily solved :roll: )

For the node editing method:
  • Select all the segments comprising the shape. If circumstances permit, you might be able to do it quicklly by dragging a selection box (or sometimes called rubberband selection) around all the segments. Or if the segments are the only content in the file, you could do Ctrl + A.
  • Path menu > Combine, as you've learned.
  • Without deselecting, switch to the Node tool :tool_node: .
  • Perform either of the previously described selection techniques again (this time, with the Node tool engaged, it will select nodes).
  • Click 'Join selected nodes' button on control bar. (I don't know how Inkscape does this, but somehow it knows which nodes to join -- what a great program!)

For the bucket tool (Fill bounded areas):
  • On the control bar is a Grow/Shrink value. You may have a little trial and error finding the setting that works best for you. I usually keep mine at 0.5, because if the stroke is only 1.0, it could grow too much in some areas, and show outside the bounded area.
  • Next you'll need to move the new filled area below the paths. Using the Selection tool, click Object menu > Lower to bottom, or there's a button on the control bar.
  • This is really optional, but I also usually enable snapping to paths. Then I snap the nodes of the new filled area to the paths. This ensures a smooth connection with no overflow. But, it's really optional, especially if the stroke widths are greater than 1.0.
  • Also optional -- Depending on your purposes, you may also want to select all the paths and the new fill, and Object menu > Group (or command bar button).

Let us know if you run into any glitches :D

guybrush
Posts: 2
Joined: Fri Mar 30, 2012 9:53 pm

Thanks for your Help

Postby guybrush » Tue Apr 03, 2012 10:21 pm

Thank you Brynn for your very detailed and helpful answer.

The first method works like a charm and is exactly what I wanted to achieve. This is perfect.

The bucket tool still leads to results that depend on the zoom level, which I find quite strange. The more I zoom, the closer it match the outside border, but if I zoom out in order to see the complete path that I want to fill, the contours of the fill zone do not follow closely the path. I don't know if this is a bug or a "feature".

But anyway, as the node merging works perfectly (I didn't get that I have to select twice: once for the segments, and once to select the nodes of the selected segments...), the bucket tool issue is not that important.

Once again, thanks for your precious help, and sorry for the late reply, but I have had some trouble reaching the inkscapeforum domain those past few days...

jcoppens
Posts: 2
Joined: Mon Apr 06, 2015 8:27 am

Re: Fill closed path made from disconnected segments[solved]

Postby jcoppens » Mon Apr 06, 2015 8:32 am

For some reason this does not seem to work in Inkscape 0.91 (dev)... I've tried several ways, even re-selecting the elements with the node editing tool enabled...

Any suggestion?


Return to “Help with using Inkscape”