First off congratulations and thank you for the 0.40 release. I'm telling everyone how much I love Inkscape.
I was wondering if anyone could offer some advice or insight. I'm writing a little PHP script to convert a subset of SVG PathData (only M, C, L and z directives) drawn with Inkscape into DXF SPLINEs (NURBs) for use in QCad. I can do it successfully following the practical instructions at the bottom of this article about NURBs http://www.mactech.com/articles/develop/issue_25/schneider.html. To do this I write a separate SPLINE for each segment of a Path. I would prefer to write a single SPLINE for each continuous portion of a Path, but I can't get it right. So far I have just been guessing and guessing wrong. Any direction would be appreciated.
Aaron Spike
Aaron Spike wrote:
First off congratulations and thank you for the 0.40 release. I'm telling everyone how much I love Inkscape.
I was wondering if anyone could offer some advice or insight. I'm writing a little PHP script to convert a subset of SVG PathData (only M, C, L and z directives) drawn with Inkscape into DXF SPLINEs (NURBs) for use in QCad. I can do it successfully following the practical instructions at the bottom of this article about NURBs http://www.mactech.com/articles/develop/issue_25/schneider.html. To do this I write a separate SPLINE for each segment of a Path. I would prefer to write a single SPLINE for each continuous portion of a Path, but I can't get it right. So far I have just been guessing and guessing wrong. Any direction would be appreciated.
Aaron Spike
Aaron,
One of the new features of this release is the exporting of SVG Paths to Bezier prisms for POVRay. I think that if you compare an SVG file with the Bezier segments that it generates, then you will probably have a good idea how to do the same for DXF.
The main idea is that you must change the MoveTo/LineTo/CurveTo data to a set of Splines, each with the start point and its control point(s), and the end point and its control point(s).
You will find *.pov on the SaveAs dialog.
Bob
Bob Jamison wrote:
One of the new features of this release is the exporting of SVG Paths to Bezier prisms for POVRay. I think that if you compare an SVG file with the Bezier segments that it generates, then you will probably have a good idea how to do the same for DXF.
I took a quick look. It seems the Bezier segments in the POV files are still Beziers. DXF does NURBs. Now I am completely clueless, but from what I understand. Beziers are special case NURBs. I guess I need to know, "when is a NURB a Bezier?" So that I can make fullfleged NURBs from the beziers I have.
The main idea is that you must change the MoveTo/LineTo/CurveTo data to a set of Splines, each with the start point and its control point(s), and the end point and its control point(s).
Correct. And I do have a working version that breaks a path into many NURBs one for each bezier segment. Works great. I was hoping to not break the paths apart. If I could do them in a single spline they would hang together and be easier to move and edit.
Alan Horkan wrote:
Dia has basic SVG import and also allows DXF Export, which might be of some use to you even if only to see how the conversions should work.
Dia breaks curves into little autonomous lines on export to DXF, but thanks for the suggestion.
I realise you probably want to do this yourself programmatically but for what it is worth I may as well suggest some alternatives.
Thanks, I do want to do this myself programmatically. Partly for my own enlightenment. But mostly to add to my little arsenal of tools. I want to build a solid body guitar plan generator online. It started with microtonal multiscaled fretboards in SVG, PDF and DXF: http://www.fretfind.ekips.org/2d/index.php
And now I'm working on body shapes: http://www.ekips.org/comp/prog/paths/patheditor.php
You can see where I'm at on that page. If you compare the output of "Make Single page PDF" and "Make Good DXF" for one of those paths you will see that they match but that each part of the curve is separate in the DXF. "Make Bad DXF" is my latest trial at combinig the Beziers in a single SPLINE. It makes one curve for each continuous path segment but the curves does look very much like the original path (eg in the PDF).
Thanks again for the suggestions. Aaron Spike
Aaron Spike wrote:
Bob Jamison wrote:
One of the new features of this release is the exporting of SVG Paths to Bezier prisms for POVRay. I think that if you compare an SVG file with the Bezier segments that it generates, then you will probably have a good idea how to do the same for DXF.
I took a quick look. It seems the Bezier segments in the POV files are still Beziers. DXF does NURBs. Now I am completely clueless, but from what I understand. Beziers are special case NURBs. I guess I need to know, "when is a NURB a Bezier?" So that I can make fullfleged NURBs from the beziers I have.
The main idea is that you must change the MoveTo/LineTo/CurveTo data to a set of Splines, each with the start point and its control point(s), and the end point and its control point(s).
Correct. And I do have a working version that breaks a path into many NURBs one for each bezier segment. Works great. I was hoping to not break the paths apart. If I could do them in a single spline they would hang together and be easier to move and edit.
Keep in mind that a SVG path is actually a set of subpaths, connected together. A single spline cannot do this, unless it is of very high order.
If this is what I think it is, then I have seen this on the web before. Maybe you want to to turn the cusps (non-continuous points on the path set) into curves?
Basically, you turn two 3d order splines into a single 4th order spline, then reduce it to the closest approximation single 3d order spline you can get. Is that right?
If you come up with a generalized Path->NURB conversion, let us know. If it is clear enough to unenlightened 3d-ers like me, maybe we can make a hardcoded export filter for it.
Bob
I was wondering if anyone could offer some advice or insight. I'm writing a little PHP script to convert a subset of SVG PathData (only M, C, L and z directives) drawn with Inkscape into DXF SPLINEs (NURBs) for use in QCad. I can do it successfully following the practical instructions at the bottom of this article about NURBs
I realise you probably want to do this yourself programmatically but for what it is worth I may as well suggest some alternatives.
I'm not sure how it works but I rememeber reading that there was a way on Linux to transparently hook Inkscape up with other applications and export to a greater selection of file formats including the AutoCAD Drawing eXchange Format (DXF).
Dia has basic SVG import and also allows DXF Export, which might be of some use to you even if only to see how the conversions should work.
Hope that helps
Sincerely
Alan Horkan
Dia is for Diagrams http://gnome.org/projects/dia/ Abiword is Awesome http://abisource.com
participants (3)
-
Aaron Spike
-
Alan Horkan
-
Bob Jamison