Add more user control over 'Path to Stroke' resolution?

Flesh out your ideas for new or improved Inkscape features before submitting a request.
dfro
Posts: 2
Joined: Wed Mar 05, 2008 8:55 am

Add more user control over 'Path to Stroke' resolution?

Postby dfro » Fri Jan 22, 2010 9:05 am

Hi everyone,

I am interested in being able to mill printed circuit boards with a cnc milling machine. To do that I need a .dxf file. Currently, the suite of software I am using, gEDA, does not yet have the ability to export the pcb artwork to dxf.

So, I worked out a method using Inkscape and pstoedit. I wrote a post on it at cnczone.com:

http://www.cnczone.com/forums/showthread.php?t=97677

A brief synopsis of what I do goes like this:

From the gEDA/pcb program, I export the finished artwork as a .ps file.
I then load the .ps file into Inkscape, 'Ungroup' it, 'Stroke to Path' it, and 'Union' it.
I save it as a .ps file.
Then I use the command line program pstoedit to run this command on the file: $pstoedit -f dxf_s <in>.ps <out>.dxf
What I am left with is a very good outline in .dxf format of the copper traces, pads, and polygons.
The .dxf file can now be loaded into a CAM program and how the copper is milled can be worked out.

***

There are two slight problems I see happening in Inkscape, though.

The first one is with the 'Stroke to Path' command. It changes the shape of the rounded ends of the lines (strokes). The perfect half circles at the end of each line are slightly altered in seemingly random ways. Here is an example of a line made in gEDA/pcb, exported as a .ps file, loaded into Inkscape, and given the 'Stroke to Path' command:

Before:

Image

After:

Image

As you can see the ends of the lines alter the shape of the 45 degree bend. At first I wondered if it could be an error in the way that gEDA/pcb creates the data contained in the .ps file. But, I did some small experiments and I found that lines (strokes) that are created in a new Inkscape .svg file exhibit the same type of errors when given the 'Stroke to Path' command. Here is an example of a green line drawn in Inkscape showing its nodes:

Image

And here is the same green line after the 'Stroke to Path' command:

Image

You can see that the ends are altered, especially on the right end of the line. On the left end the nodes are not spaced equally.

These slight alterations to the ends of the lines show up in the final .dxf file, as well. Here are some close-ups in qcad of what the pcb artwork outlines look like after being converted from .ps to .dxf using 'pstoedit':

Image

Image

The perfect 45 degree rounded corners created in gEDA/pcb are now quite lumpy and bumpy. My hope is that the Inkscape developers improve the results of the 'Stroke to Path' command. Perhaps in future updates, Inkscape could provide the user with some control over increasing the resolution of the conversion from stokes to paths.

***

Secondly, Inkscape's ability to save files in the .dxf format could be improved, in my opinion. The circles and curves are not reproduced well enough. I do not know how Inkscape does the conversion to .dxf. But, if it is using pstoedit as a backend, have the developers considered using the '-f dxf_s' option in pstoedit? It gets a much better result than '-f dxf'. The 'dxf_s' option handles splines and curves better, and produces a more accurate result.


Let me know what you think.

Thanks,
Dave

User avatar
RobA
Posts: 335
Joined: Fri Aug 10, 2007 1:22 am

Re: Add more user control over 'Path to Stroke' resolution?

Postby RobA » Fri Jan 22, 2010 4:42 pm

Interesting! It looks like rounding errors.

Try this:

Make a stroke at a 45degree angle that is 100px wide, rounded caps and corners.
Duplicate it. Use path to stroke, and change the colour and opacity. Every thing is nice.

Now with scale stroke toggled on, take both the path and path to stroke copy and scale them down. (I used the transform command and put in 1%). Notice now, the two no longer line up.

No good answer except to try working at a larger scale.
In your workflow, after importing the ps file, scale it up by 1000 then ungroup, stroke to path ...
then add "-scale 0.001" or "-xscale 0.001" "-yscale 0.001" (depending on your version of pstoedit) to the call.

See if that works.

-Rob A>

dfro
Posts: 2
Joined: Wed Mar 05, 2008 8:55 am

Re: Add more user control over 'Path to Stroke' resolution?

Postby dfro » Sat Jan 23, 2010 5:34 am

Rob,

Thanks for the help. I tried what you suggested, and yes the rounded caps on the strokes turned out much better after scaling x100. However, pstoedit was not able to do a good job of scaling the image back down. All of the curves came out very bumpy and ragged. I used this command: $pstoedit -xscale .001 -yscale .001 -f dxf_s <in>.ps <out>.dxf

Also, by scaling x100 in Inkscape and then doing 'Path to Stroke' and 'Union', a new set of problems arose. gEDA/pcb creates solid ground plane polygons that are butted up against each other, and meant to be treated as one solid object. At x100 scale, tiny slivers of white background showing between them. They are not 'boolean union'-ing into a single object when the image is scaled x100.The scaling seems to be slightly offsetting the nodes now.

Based on your advice, I was however able to improve the image a little. I scaled it x10, did all the operations on it, and scaled it back down by the same factor within Inkscape. I then saved as a .ps and did the pstoedit operation without any scaling. I was able to get some smoothing of the corners that way.

Maybe the 'Path to Stroke' rounding errors should be reported as a bug. What do you think?

Thanks,
Dave

User avatar
RobA
Posts: 335
Joined: Fri Aug 10, 2007 1:22 am

Re: Add more user control over 'Path to Stroke' resolution?

Postby RobA » Mon Jan 25, 2010 12:43 pm

You can try reporting a bug, but it may just be a limit of floating point resolution. I don't really know.

-Rob A>


Return to “Inkscape Ideas”