(2022-12-09, 21:18)Jose Alfonso Wrote: Although it is not a direct method, you can use Blender:
- File -> Import -> Scalable Vector Graphics (the resulting object is a path)
- Object Mode -> Object -> Convert -> Mesh (to get a triangulated shape)
- Object Mode -> Add Modifier -> Decimate (to reduce the number of faces when necessary)
- Edit Mode -> Face -> Tris to Quads (to convert some triangles to quadrilaterals)
- Export -> LDraw (you need to install the free extension ExportLdraw)
That's true, I always forget that you can go through Blender for some things.
The method I've devised for Inkscape is fiddly, but accurate. You have to:
- Break your path apart to separate linear from Bezier segments;
- Use "Add Nodes" on the Bezier segments ("Flatten Beziers" didn't give me the expected result) to get the appropriate number of vertices for LDraw precision;
- Convert all segments between these nodes from curved to linear;
- Re-assemble your path (you'll also want to render/commit any path effects, remove matrix transforms, etc.);
- Run the "To Absolute" extension on your path so that the SVG outputs only X,Y pairs for the path nodes instead of relative translations;
- Then from the XML editor you can select and copy/paste the code for the path ("d") element;
- Now you have to do some find/replace text editing to convert the pasted code into, say, LDPE vertex lines, which you can then triangulate.
It's a lot of steps, but most of it is pretty rudimentary tasks that are probably easy to code. The only math-intensive step would be interpolating the additional nodes; otherwise, you can just strip control points from Bezier nodes, re-format the lines to LDraw spec, maybe even take the SVG transform tag and apply the matrix transform, if present.