Welcome to the Onshape forum! Ask questions and join in the discussions about everything Onshape.

First time visiting? Here are some places to start:
  1. Looking for a certain topic? Check out the categories filter or use Search (upper right).
  2. Need support? Ask a question to our Community Support category.
  3. Please submit support tickets for bugs but you can request improvements in the Product Feedback category.
  4. 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_mochelkarl_mochel Member Posts: 53 ✭✭

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:

Comments

  • martin_kopplowmartin_kopplow Member Posts: 1,067 PRO

    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.

  • bryan_lagrangebryan_lagrange Member, User Group Leader Posts: 942 ✭✭✭✭✭

    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.

    Bryan Lagrange
    Twitter: @BryanLAGdesign

  • bryan_lagrangebryan_lagrange Member, User Group Leader Posts: 942 ✭✭✭✭✭

    some .svg files work some don't

    Bryan Lagrange
    Twitter: @BryanLAGdesign

  • karl_mochelkarl_mochel Member Posts: 53 ✭✭

    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.

  • karl_mochelkarl_mochel Member Posts: 53 ✭✭

    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.

  • bryan_lagrangebryan_lagrange Member, User Group Leader Posts: 942 ✭✭✭✭✭

    I was downloading samples from SVG Repo. https://www.svgrepo.com/ to test. I had issues with these .svg files.

    Bryan Lagrange
    Twitter: @BryanLAGdesign

  • karl_mochelkarl_mochel Member Posts: 53 ✭✭

    @bryan_lagrange Check out the new version. Should work now. You can see the test ones I pulled work now.

  • bryan_lagrangebryan_lagrange Member, User Group Leader Posts: 942 ✭✭✭✭✭

    I will try it. Thanks for the update.

    Bryan Lagrange
    Twitter: @BryanLAGdesign

  • bryan_lagrangebryan_lagrange Member, User Group Leader Posts: 942 ✭✭✭✭✭

    I tried 2 .svg files and both worked. Excellent work!

    Bryan Lagrange
    Twitter: @BryanLAGdesign

  • jelte_steur_infojelte_steur_info Member Posts: 595 PRO

    whaa, this is awesome!
    Especially for logo imports that now have to go through dxf!
    I'm also interested in your featurescript_guidelines.md !

  • S1monS1mon Member Posts: 3,753 PRO

    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?

    image.png

    Simon Gatrall | Product Development Specialist | Open For Work

  • EvanReeseEvanReese Member, Mentor Posts: 2,685 PRO

    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?

    Evan Reese
    The Onsherpa | Reach peak Onshape productivity
    www.theonsherpa.com
  • Derek_Van_Allen_BDDerek_Van_Allen_BD Member Posts: 389 PRO

    @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.

  • karl_mochelkarl_mochel Member Posts: 53 ✭✭
    edited December 9

    @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

  • karl_mochelkarl_mochel Member Posts: 53 ✭✭

    @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.

  • karl_mochelkarl_mochel Member Posts: 53 ✭✭

    @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.

Sign In or Register to comment.