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.
opBoolean() with BooleanOperationType.INTERSECTION fails with @opBoolean: BOOLEAN_BAD_INPUT
blackslate
Member Posts: 18 ✭
Hello Helpful Onshapers!
I want to use opBoolean() to "take a bite" out of a solid model. I imagine that this should be done in two steps:
1. Use BooleanOperationType.INTERSECTION to create a "mouthful" of the target
2. Use BooleanOperationType.SUBTRACTION to remove that mouthful
I then plan to put the body created in step 1 back in the gap created by step 2, so that it can be shown and hidden as needed.
Step 2 is working fine. Step 1 creates the error @opBoolean : BOOLEAN_BAD_INPUT, when using exactly the some definitions map as step 1… except that the "operationType" is different.
The error occurs on line 73 of the Main feature script in this workspace:
https://cad.onshape.com/documents/1776f4d7e0da1375f085688a/w/4a622666db4ebdaef2534d40/e/46830a65962f82e472873711?renderMode=0&uiState=69381ff68808f7bd63038112
Any help will be most appreciated!
James
Comments
Copied Onshape doc
It's a bit confusing to understand what you're trying to do without the goal modeled in CAD for us to compare with. However, if I understand correctly, the spineCubes are cubes running diagonally down the "spine" of the pyramid. And you're trying to intersect those with the pyramid. I think you're doing it in a for loop because I tried doing them all at once and that didn't quite work. Is that correct?
Here's what I saw. Below is the "corrected" code:
toolsandtargetfor Intersection, which isn't valid. You just needTools, from what I see in the Standard Library Documentation.spineId, you need to put the index before the feature name or else you'll get an error.keepToolsin your boolean subtract, but I'm not sure what the intent is.targetsAndToolsNeedGroupingfor (var ii = 0; ii < size(spineCubes) ; ii += 1 ) { const spineId = id + ii+ "spine"; const spineCube = qUnion([ spineCubes[ii], pyramid]); const options = { "tools": spineCube, "operationType": BooleanOperationType.INTERSECTION, "keepTools": true };Ramon Yip | glassboard.com
you could consider BooleanOperationType.SUBTRACT_COMPLEMENT if you want to essentially do an interesection but keep the control over tool/target. (because target retains it's identity), and allow multiple tools to intersect with only one target.
This may make your for loop obsolete
I just cleaned up a community made feature with that trick @jelte_steur_info. I kind of wish that was just the default behavior of intersect
Derek Van Allen | Engineering Consultant | Meddlerjust FYI: I just took the effort to publish the basic boolean feature
Thank your @ry_gb for your solution. It works well, even though I do not understand why…
const spineId = id + "spine" + ii;
… causes an error when you use…
"operationType": BooleanOperationType.INTERSECTION
… but not when you use:
"operationType": BooleanOperationType.SUBTRACTION
—-
To give some context to my question, and to respond to your comment "It's a bit confusing to understand what you're trying to do…"
For a maths class, I am building a physical demonstration of the formula for a square pyramidal number. My completed demonstration will show that the volume of a stepped pyramid with a base n-squared will be:
the volume of a smooth pyramid with the same dimensions
+ the sum of all integers from 1 to n
- n / 3
The part "sum of all integers from 1 to n" is the total additional volume of the steps, and the part "- n / 3" is where the steps intersect the pyramid — in other words, the little "spine" pyramids that you have helped me to remove from the pyramid itself.
I'm not entirely sure why it worked with Subtraction, but not Intersection.
I'm kinda new to FeatureScript so I don't entirely understand everything yet, but it looks like from FeatureScript Fundamentals course, they do mention you want to put the index before the string because you can't revisit ID's
Link to video
Ramon Yip | glassboard.com