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.

How do I replicate the Use/Project sketch functionality in FS code?

pmdpmd Member, Developers Posts: 63 PRO
I am trying to write some FS code to flatten sloping faces as part of the cleanup of a 3D model to make it 2.5D for our router. For our purposes we just want pockets with all edges at 90 degrees so if we had a 45degree slope we would just "press it down" until it was flat. The perimeter of the pockets can be any profile (concave or convex).

My current code is here: https://cad.onshape.com/documents/5c235881abd08b64e0f3ebbf/w/7de1890964778476c2f32190/e/1d4ef221139f383005cc307c

It takes a face as input, finds the bounding edges and attempts to construct a sketch on a plane passing through the lowest point on the sketch which is then used for extrude tool followed by boolean subtract.

The problem is I could not work out how to project arbitrary edges down onto a plane - the code only works if all the edges are lines. Put in non-lines like arcs and it breaks - see the last feature call to FlattenSlope2 using the arcs-only sketch.

ilya_baran seemed to say that there was no such functionality:
https://forum.onshape.com/discussion/comment/23557#Comment_23557 but I was hoping this may have changed since then.

I feel that there must be a simple way to do this but have failed to find it.

Any ideas?
Tagged:

Best Answer

Answers

  • NeilCookeNeilCooke Moderator, Onshape Employees Posts: 5,663
    Probably the best way to do this would be to extrude the edges as surfaces up to a plane then use the edges created by the surface.
    Senior Director, Technical Services, EMEAI
  • pmdpmd Member, Developers Posts: 63 PRO
    Still struggling with this. I used suggestion from @NeilCooke to extrude edges as surfaces to the cutting plane and this looks like it will do the projection I want so currently have:


    but next question is how do I convert these edges to a solid I can extrude up and then boolean subtract?

    https://cad.onshape.com/documents/5c235881abd08b64e0f3ebbf/w/2fa5b31ddd77d8a4ed2bc093/e/1d4ef221139f383005cc307c

    I am using qCoincidesWithPlane(extruded_surface_edges, cutting_plane) to extract the 'projected' boundary I want but this query just contains edges and vertices so when extruded I just get surfaces. I have searched for a way to convert edges to faces so I can extrude a solid but not found anything yet.
     
  • pmdpmd Member, Developers Posts: 63 PRO
    @Jake_Rosenfeld

    Thanks - that was it. I was searching on "face" rather than "surface"
  • pmdpmd Member, Developers Posts: 63 PRO
    I made some progress on this and for simple cases it works fine but need another hint on how to deal with multiple loops since FillSurface returns an error FILL_SURFACE_MULTI_LOOP if feed more than one loop.



    The red lines are the edges being fed into opFillSurface.

    Latest code is:
    https://cad.onshape.com/documents/5c235881abd08b64e0f3ebbf/w/2fa5b31ddd77d8a4ed2bc093/e/1ee3512e4a426a5d4b3faf21

    I did try looping over each surface created when projecting down to the cutting plane but this does not work since order dependent - in the above case I end up with a circle and and square which then cuts away too much - I really want a square donut shape and the collection of edges I have seems to have no inner/outer structure I could use to order things.

Sign In or Register to comment.