Time to revisit SVG path to LDraw conversion?


Time to revisit SVG path to LDraw conversion?
#1
Yes, I'm thinking it's time!

Every pattern I create (which admittedly isn't that many yet) seems to involve passing through the SVG format at some point. But we're still missing a tool for converting SVG graphics directly to LDraw, and I know there have been a couple started already. (Img4Dat has planned SVG functionality, SvgToDat I believe handles basic primitives only, etc.)

My proposal is to start with the single task of converting SVG paths to vertices that can be imported, say, into LDPE at a reasonable resolution for mesh generation. And since SVG paths are really just a combination of cartesian coordinates (rel or abs) and Bezier control points, all that's really needed is a way to take the cubic Bezier math and make a polyline out of that—perhaps with an option between points evenly spaced, or according to curvature (so that tighter curves get more points). Best of all, that information is already stored in a nice, human-readable xml format within the svg file.

The use case for this arose when working on this part. I was able to lift those vectors directly from the official instruction booklet, put them into Inkscape, export a PNG and trace that manually in LDPE. But how much faster if I could have taken the paths themselves (or the xml data from inside the svg file) and drop them into a tool in LDPE, maybe adjust the precision a little bit, and instantly have the vertices I need to triangulate the pattern!

I'm thinking—in fact, I'm sure—that the math part of this has already been worked out many times over, and all that's missing is to code it in a way that's specific to LDraw. If we only focus on converting paths (which, again, is really just converting Bézier curves), then it think it becomes much easier to tackle than trying to incorporate the entire SVG spec into an LDraw tool, because a lot of that is probably stuff we can do more or less by hand.

So who's up for the challenge, and how can I help? I never learned to code, though I do understand programming languages generally. I just don't know a git from a commit from a pull request. ;-) And I'm not fluent in math, but I can figure out problems on an ad hoc basis, or at least look up the answers!
Reply
« Next Oldest | Next Newest »



Messages In This Thread
Time to revisit SVG path to LDraw conversion? - by N. W. Perry - 2022-12-08, 15:32
RE: SVG... - by Franklin W. Cain - 2022-12-15, 14:53
RE: SVG... - by Orion Pobursky - 2022-12-15, 15:38

Forum Jump:


Users browsing this thread: 1 Guest(s)