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: 47 ✭✭

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,057 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: 940 ✭✭✭✭✭

    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: 940 ✭✭✭✭✭

    some .svg files work some don't

    Bryan Lagrange
    Twitter: @BryanLAGdesign

  • karl_mochelkarl_mochel Member Posts: 47 ✭✭

    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: 47 ✭✭

    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: 940 ✭✭✭✭✭

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

    Bryan Lagrange
    Twitter: @BryanLAGdesign

Sign In or Register to comment.