Time to revisit SVG path to LDraw conversion?


RE: Time to revisit SVG path to LDraw conversion?
#4
(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:
  1. Break your path apart to separate linear from Bezier segments;
  2. 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;
  3. Convert all segments between these nodes from curved to linear;
  4. Re-assemble your path (you'll also want to render/commit any path effects, remove matrix transforms, etc.);
  5. 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;
  6. Then from the XML editor you can select and copy/paste the code for the path ("d") element;
  7. 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.
Reply
« Next Oldest | Next Newest »



Messages In This Thread
RE: Time to revisit SVG path to LDraw conversion? - by N. W. Perry - 2022-12-11, 4:42
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)