Skip to content

Conversation

@rwb27
Copy link

@rwb27 rwb27 commented Aug 28, 2025

This adds a few utility functions that can load a path from an SVG file and draw them on a box. I have tested only two files, which worked - I'll attach the OFM logo here.

I have also attempted to make a more neutral SVG in Inkscape and in OpenSCAD - but unfortunately neither worked properly. I think that means these functions are unlikely to be very useful without further testing. Nonetheless I'll leave them here in case it's of use to anyone.

@rwb27
Copy link
Author

rwb27 commented Aug 28, 2025

Here are some example SVG files I've used that work.
logo_emblem
shelf_cutout
footprint
footprint_cable_tidies

@rwb27
Copy link
Author

rwb27 commented Aug 28, 2025

Here are some examples that failed.
openscad_smiley
smiley

@MartinScharrer
Copy link
Contributor

Here are some examples that failed. openscad_smiley smiley

Hi, they fail how? The resulting image is incorrect?

I did some similar code in my fork this week (to draw a logo and special cutouts imported from SVG) and I noticed that having multiple z commands in the path does not work, i.e. generates an incorrect image. You need to close the path so far every time a z or Z command is encountered. This should fix the issue.

I added this indirectly by calling ctx.stroke on Z but calling a close-path command might be better. Feel free to compare my code at https://github.com/MartinScharrer/boxes/blob/51598cef72447fa54ddd7c31ee17fd74fa8bed4d/boxes/generators/queentransportbox.py#L121

@MartinScharrer
Copy link
Contributor

MartinScharrer commented Nov 5, 2025

The issue #847 might be relevant here. Maybe this is the reason some SVGs fail to render properly. Curves can then changed to edge polylines!

I fixed it as PR #848.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants