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.

Why is this draft failing? In general, opDraft vs. draft?

Stormi_BackusStormi_Backus Member Posts: 49
Howdy, 

I am working on a taper lock bushing feature script and cant get the draft for my taper to work. I've tried many variations of opDraft and draft but no success with either. The link to my public document is here and there's a screenshot of my current draft attempt/error warning below. That is my immediate issue, but I have a more general question I'll tack on here:

What is the difference between opDraft and draft? opExtrude and extrude? I regularly run into issues in FeatureScript where extrude doesn't work but if I try and opExtrude instead it does...I have no idea why and that suggests a gap in understanding I'd like to fill!

Thanks in advance,
Stormi 


Best Answer

  • EvanAReeseEvanAReese Member, Mentor Posts: 2,077 1337
    edited September 2023 Answer ✓
    Anything starting with op is what you want to default to since it's lighter weight. The non "op" function is the actual native feature you get when you click the feature icon to use it in a part studio, which means it carries with it a ton of extra code you may not need. For example: opExtrude() just extrudes a face in a direction, but you have to draft and boolean it yourself later. extrude() performs opExtrude() but also handles all of the options for draft, starting offsets, thin extrude, sheet metal, booleans, etc. If you need all of those things done too, then use extrude() and don't reinvent it, but if you need something simpler, opExtrude() is more efficient to write and compute.

    In your case, your draft is failing because you've queried every face of your extrude, including the end caps. Use this query instead:
    const facesToDraft = qNonCapEntity(id + "MainBodyExtrude", EntityType.FACE);
    To make your code more adaptable, I'd also drive the draft direction with the sketch plane, so you could move the sketch plane around and still draft as expected:
    const draftDirection = TopFace.normal;

    Evan Reese / Principal and Industrial Designer with Ovyl
    Website: ovyl.io

Answers

  • EvanAReeseEvanAReese Member, Mentor Posts: 2,077 1337
    edited September 2023 Answer ✓
    Anything starting with op is what you want to default to since it's lighter weight. The non "op" function is the actual native feature you get when you click the feature icon to use it in a part studio, which means it carries with it a ton of extra code you may not need. For example: opExtrude() just extrudes a face in a direction, but you have to draft and boolean it yourself later. extrude() performs opExtrude() but also handles all of the options for draft, starting offsets, thin extrude, sheet metal, booleans, etc. If you need all of those things done too, then use extrude() and don't reinvent it, but if you need something simpler, opExtrude() is more efficient to write and compute.

    In your case, your draft is failing because you've queried every face of your extrude, including the end caps. Use this query instead:
    const facesToDraft = qNonCapEntity(id + "MainBodyExtrude", EntityType.FACE);
    To make your code more adaptable, I'd also drive the draft direction with the sketch plane, so you could move the sketch plane around and still draft as expected:
    const draftDirection = TopFace.normal;

    Evan Reese / Principal and Industrial Designer with Ovyl
    Website: ovyl.io
  • Stormi_BackusStormi_Backus Member Posts: 49
    @Evan_Reese that makes perfect sense - thanks for the explanation!
Sign In or Register to comment.