Export sketch as piecewise polyline.

brad_phelan
brad_phelan Member Posts: 91 ✭✭

It's been a while since I've written any featurescript. I'm looking for the following solution. I would like to be able to select N closed and open chains of sketch entities and with a provided tolerance tesselate them into N piecewise polylines and then either print them to the console or copy them to the clipboard. Is this relatively simple?

Comments

  • NeilCooke
    NeilCooke Moderator, Onshape Employees Posts: 6,126 image

    Would be easier to export as DXF with "export splines as polylines" option

    Senior Director, Technical Services, EMEA
  • brad_phelan
    brad_phelan Member Posts: 91 ✭✭
    edited August 2025

    Not really. I want a simple tool I can use to generate me polylines I can paste directly into a c++ program as test data. Using the OnShape sketcher and having a tool that can copy the sketch data to the clipboard as a

    std::vector<std::vector<Point2D» foo = { …… }

    is what I would like to have. It would probably exporting DXF and then processing that DXF with another tool to get what I want but it would be nice to have an all in one UI driven by featurescript that would do this for me. I can't imagine this useful to anyone else but me ;)

  • Derek_Van_Allen_BD
    Derek_Van_Allen_BD Member Posts: 1,165 PRO

    You're not the only one who has a use for a tolerance based polyline script. When I did my Delaunay Triangulation script I settled for a basic global resolution subdivision script but there are times when I'll want more local curvature aware tolerancing for this and other scripts I'm working on. Export-import routines probably work for a lot of applications but it's definitely cleaner to keep everything at the feature level in my opinion.