easy to convert existing SVG to mm?

Given that’s part of Rack’s code, it’s not up to us. Andrew has been clear that SVG files with units in millimeters is a requirement, even though modules with pixel units still work and many Fundamental and Rack component library SVG files still have units in pixels. Because he uses the word requirement, it’s possible that Rack might change in a future version in order to actually require mm unit SVG.

At least as far as the Rack component library, and any third-party library like @persy is trying to get going, I think that requiring millimeters is actually a good thing. If you start a panel layout working in millimeters and then try to pull in component graphics in order to work on layout and spacing, it becomes a chore if the component you’re pulling in has some other scaling factor (DPI). I described some trouble with this issue in this thread.

This seems to be the best way in Inkscape:

  1. Under the File menu, open “Document Properties”. On the Page tab, change both “Display units” under General and “Units” under Orientation → Custom Size to mm rather than px.
  2. Under Orientation → Custom Size, take note of the current Height in mm. In my experience, this will probably not be 128.5mm. Determine the scaling factor necessary to convert it to 128.5mm, i.e. divide 128.5 by your current height. Save this scaling factor for later.
  3. Note the current width and save it for later.
  4. Multiply the width by the scaling factor obtained in step 2. Then, divide this result by 5.08mm. In my experience, the result will probably not be a round number but rather something like “25.9609409449”. Round that to the nearest integer, then multiply that times 5.08. In this case that would be 26 * 5.08 = 132.08.
  5. Determine the scaling factor necessary to convert the original width (saved in step 3) to the correct number obtained in step 4 (eg. 132.08). Save this scaling factor for later.
  6. Change the width to the new width (eg. 132.08mm) and the height to 128.5mm.
  7. Close Document Properties. Under the Edit menu choose “Select All in All Layers” (ctrl+alt+a). Under the Object menu, select “Transform…” (shift+ctrl+m).
  8. In the Transform dialog, choose the Scale tab. Uncheck “Scale proportionally”. Uncheck “Apply to each object separately”. Enter the scaling factors that you saved earlier (Width in step 5 and Height in step 2), multiplied by 100 (to convert to percentage). Click “Apply”.
  9. Under the Object menu, select “Align and Distribute…” (shift+ctrl+a).
  10. In the Align and Distribute dialog, Select “Page” in the “Relative to:” selector.
  11. Click the button next to the “Relative to:” selector. The tooltip for this button should read “Treat selection as group”. Make sure that is enabled.
  12. Click the third button from the left in each of the first two rows: the tooltips for these buttons should read “Center on vertical axis” and “Center on horizontal axis”

That should do it. I expected to have to obtain new coordinates for component placement in the module code, especially given the ever-so-slightly different scaling factors I applied to width and height, but it seems that the existing code remains valid even if it is using pixel coordinates from the old (non-rescaled) panel. I guess this is because Rack was already scaling my graphics differently on the x and y axis and I never noticed the slight difference?

Maybe there is a faster way, in Inkscape and/or other software?

Edit: Missed multiplication, wording for clarity

2 Likes