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.
Help with featurescript subtraction
calvin_selin
Member Posts: 8 EDU
I think my code's probably super messy, so sorry.
So, I'm trying to make a featurescript that will make holes in the end of square tubes. I got it to make a sketch with a circle, and Extrude it through all, but when I run the subtraction, it doesn't work. Do ya'll know why?
this is my intended result, if it helps.
If you can help, thank you!
Tagged:
0

Comments
I suspect that your issue is the queries that you're passing ito the boolean:
"tools" : qCreatedBy(id + "extrude" + i), → All entities created by (id + "extrude" + i). Bodies, Faces, Verticies, Edges, etc. Note that I'd recommend changing this code to qCreatedBy(id + ("extrude" ~ i)). Id's can get brittle, and I've found that concatenated pattern to work well.
"targets" : evaluateQuery(context, qOwnerBody(qUnion(faces))), —> This seems like a backwards way to get what you're looking for. Why not just pass the part in as a parameter?
As a quick fix/test, I'd do the following:
I did the first thing, but it didn't fix it.
What do you mean by a debug entity?
I'd look into the featurescript classes at learn.onshape.com. I'd also look at how you're getting entities with qCreatedBy - when you type it out, tooltips pop up and could help you get the query you're actually looking for. addDebugEntities is a way of highlighting certain entities which is really helpful when debugging a feature (and occasionally, to make feature operation more intuitive to the user).
Fixed it.
Here's what I put for the Boolean
opBoolean(context, id + "boolean1", {
"tools" : qCreatedBy(id + ("extrude" ~ i), EntityType.BODY),
"targets" : qOwnerBody(face),
"operationType" : BooleanOperationType.SUBTRACTION
});