Welcome to the Onshape forum! Ask questions and join in the discussions about everything Onshape.
First time visiting? Here are some places to start:- Looking for a certain topic? Check out the categories filter or use Search (upper right).
- Need support? Ask a question to our Community Support category.
- Please submit support tickets for bugs but you can request improvements in the Product Feedback category.
- 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.
I'm stuck on something I'm sure is simple
EvanReese
Member, Mentor Posts: 2,135 ✭✭✭✭✭
Hi everyone. I've got essentially zero coding experience, so I hope I'm missing something that will be obvious to people. I'm trying to write a script that will find all of the sharp edges of a body and highlight them with the debug function. This will help me evaluate models before I send them off for injection molding since no edges should be sharp except shutoffs. Here's what I have so far, but I'm not getting any red edges:
<div>FeatureScript 961;</div><div>import(path : "onshape/std/geometry.fs", version : "961.0");</div><div><br></div><div>annotation { "Feature Type Name" : "Find Sharp Edges" }</div><div>export const findSharp = defineFeature(function(context is Context, id is Id, definition is map)</div><div> precondition</div><div> {</div><div> annotation { "Name" : "Body to Search", "Filter" : EntityType.BODY && BodyType.SOLID, "MaxNumberOfPicks" : 1 }</div><div> definition.body is Query;</div><div> </div><div> </div><div> }</div><div> {</div><div> var smooth is Query = qOwnedByBody(definition.body, EntityType.EDGE && EdgeConvexityType.SMOOTH);</div><div> var all is Query = qOwnedByBody(definition.body, EntityType.EDGE);</div><div> var sharp is Query = qSubtraction(all, smooth);</div><div> debug(context, sharp);</div><div> });</div>
Evan Reese
0
Comments
By the way, to get the code block to work in a post like this, set it to code first then paste your code into the block.
To get the code to paste correctly, you should hit the "code" formatting option, then paste your code into the blank yellow box that appears (not paste the code then highlight and press the "code" button).
This is the code that you want:
@Jake_Rosenfeld this looks like a good solution, but I don't have time to dig into it right now. Thanks for the help!
@NeilCooke Thanks! I'll look into this sometime soon, and compare your and Jake's solutions to see what I can learn. For now, I've got actual deadlines on some other stuff.