Welcome to the Onshape forum! Ask questions and join in the discussions about everything Onshape.
First time visiting? Here are some places to start:- Looking for a certain topic? Check out the categories filter or use Search (upper right).
- Need support? Ask a question to our Community Support category.
- Please submit support tickets for bugs but you can request improvements in the Product Feedback category.
- Be respectful, on topic and if you see a problem, Flag it.
If you would like to contact our Community Manager personally, feel free to send a private message or an email.
Have dev'd a SVG to Sketch Custom Feature
karl_mochel
Member Posts: 53 ✭✭
in General
Try it here!
Since FeatureScript cannot access SVGs as a blob, you need to change your SVG's file extension to *.txt to load it as a blob that the feature can access.
Was created by vibe-coding, so I also made a featurescript_guidelines.md doc to help any LLM write FeatureScript. Let me know if you are interested.
Tagged:
4
Comments
So what you say is your script does IMPORT the SVG files disguised as text, or do you imply it would also EXPORT as SVG using the same bypass?
I believe many would be interested, for just changing the file name extension would be much less hassle than going though exporting as drawing and using an external converter/editor application. Also, importing from one of the known graphics and illustration apps is an everyday thing for many, and streamlining that would be welcome.
I doubt that any SVG exported from Onshape will be suitable to be sent to the CNC right away, so there'll still be a need to edit or prepare it, but if at least one onversion step could be avoided, that'd still be someting.
The script imports a .svg as a sketch of 2D vector geometry that you can use in Onshape. Currently if you import a .svg into Onshape it comes in as an image that you have to trace over to get geometry to use.
I did just a quick test where I exported a .svg of a 2d square from CorelDraw, added a .txt to the extension. imported the .txt file into onshape and used the feature script to get vector geometry of the square that I made an extrude from.
Twitter: @BryanLAGdesign
some .svg files work some don't
Twitter: @BryanLAGdesign
The script doesn't do the import. User imports the SVG as a TXT. I asked Onshape support about reading an SVG blob directly, but it isn't on their roadmap. The FS does a fine job of converting the curves so they are usable for extrusion or other further actions. I'd like to add constraints, but that doesn't get passed through a Use feature, so I can't help with that step. I was able to make it assume dashed lines are Onshape construction lines, which is useful.
I started writing a full extension so it could read SVGs and convert them to OnShape sketches but that requires a much heavier lift since you have to deal with OAuth and APIs. While this isn't as functional it gets the job done.
If you want, you can send them my way, and I can try to see why not.
It currently (as of v35) doesn't process defs, so if your file uses those it may not process it.
I was downloading samples from SVG Repo. https://www.svgrepo.com/ to test. I had issues with these .svg files.
Twitter: @BryanLAGdesign
@bryan_lagrange Check out the new version. Should work now. You can see the test ones I pulled work now.
I will try it. Thanks for the update.
Twitter: @BryanLAGdesign
I tried 2 .svg files and both worked. Excellent work!
Twitter: @BryanLAGdesign
whaa, this is awesome!
Especially for logo imports that now have to go through dxf!
I'm also interested in your featurescript_guidelines.md !
This is really exciting. I'm also interested in your featurescript_guidelines.md. Perhaps a separate thread on your vibe coding process?
I'm a bit confused why there are 3 custom features and their naming. Can this be clarified or cleaned up?
Simon Gatrall | Product Development Specialist | Open For Work
This is a really cool idea! I've used Google Apps Script to build a converter that takes jpg and returns it as a csv so features can read it, but I like the simplicity of just making it txt. I've tried a few examples with this feature though and haven't had luck. Thoughts?
The Onsherpa | Reach peak Onshape productivity
www.theonsherpa.com
@S1mon I'm curious about the vibe coding platform being used too. My Codex method has been kinda cooked since Codex 5.1 and lately I've been pointing Github copilot and Claude at my mirrored feature library but I'm sure I'm not being optimal with token usage or context by pointing them at the whole entire library of every custom feature I've ever copied or modified.
Derek Van Allen | Engineering Consultant | Meddler@jelte_steur_info
@S1mon In the latest version there should just be an SVG to Sketch 46.2 FS tab. That is all you need.
https://cad.onshape.com/documents/e37c5dc041b343cb6bde607d/w/f7b0bf8a214658dc31c353f6/e/7217f6a6f01abf2583a1d61c?renderMode=0&uiState=69388fdff20ff15b50aa8344
@Derek_Van_Allen_BD For this last pass, I mostly used Claude in the browser. An amount of work was done with Cursor, but it stalled on some issues.
On complex projects, I switch among Claude, ChatGPT, Gemini, and Grok to see which best resolves issues. The guidelines are essential, so each model doesn't need to relearn those lessons.
@EvanReese Need the SVGs your are trying to figure out the issues, otherwise…
If you want to try to solve them yourself, I suggest grabbing the guidelines and latest FS. Then enable debugging in the feature, copy the results to an LLM with the SVG file and guidelines, and ask it to fix the problem. That's what I do.