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.
using pre-existing predicates
EvanReese
Member, Mentor Posts: 2,135 ✭✭✭✭✭
I'm trying to add all of the merging magic of the native extrude feature to my Speaker Pattern feature.
As someone uneducated in programming of any kind, I'm trying to understand how to use some of the code that is re-used across features, like the booleanStepTypePredicate and booleanStepScopePredicate. My understanding is that it lets the same code be written once and instantiated across different features (since booleans in Revolve and Extrude behave the same way, for example). What I'm not understanding is how to use it to boolean bodies. It seems like there's a function to use instead of opBoolean that will automatically take the correct inputs and just work, but I'm having a tough time understanding how to do that from looking at the native features (even very early versions of them, which I assume are simpler to understand).
I'd love advice of any kind. Explanations are preferred, but straight up solutions are also appreciated.
As someone uneducated in programming of any kind, I'm trying to understand how to use some of the code that is re-used across features, like the booleanStepTypePredicate and booleanStepScopePredicate. My understanding is that it lets the same code be written once and instantiated across different features (since booleans in Revolve and Extrude behave the same way, for example). What I'm not understanding is how to use it to boolean bodies. It seems like there's a function to use instead of opBoolean that will automatically take the correct inputs and just work, but I'm having a tough time understanding how to do that from looking at the native features (even very early versions of them, which I assume are simpler to understand).
I'd love advice of any kind. Explanations are preferred, but straight up solutions are also appreciated.
Evan Reese
0
Best Answer
-
NeilCooke Moderator, Onshape Employees Posts: 5,686Hi Evan, don't worry, it took me a while to get my head around it.
When you call booleanStepScopePredicate(definition), it substitutes "definition" for "booleanDefinition" in the code block above. It would have been clearer if they just stuck with "definition".
So in that code block, at runtime it is really testing definition.operationType which was set when you called booleanStepTypePredicate(definition). Therefore, in your opBoolean code, test for definition.operationType == NewBodyOperationType.ADD (for example) and get the bodies to add from definition.booleanScope.
It's also extremely useful to look at the source code for inspiration: https://cad.onshape.com/documents/12312312345abcabcabcdeff
Hope that makes sense. Happy to jump on a call to walk you through it.Senior Director, Technical Services, EMEAI6
Answers
That and I'm just trying to learn more about what's under the hood of the professionally written features.
When you call booleanStepScopePredicate(definition), it substitutes "definition" for "booleanDefinition" in the code block above. It would have been clearer if they just stuck with "definition".
So in that code block, at runtime it is really testing definition.operationType which was set when you called booleanStepTypePredicate(definition). Therefore, in your opBoolean code, test for definition.operationType == NewBodyOperationType.ADD (for example) and get the bodies to add from definition.booleanScope.
It's also extremely useful to look at the source code for inspiration: https://cad.onshape.com/documents/12312312345abcabcabcdeff
Hope that makes sense. Happy to jump on a call to walk you through it.
Here's where I am with it so far
here's an illustration of the issue I'm having. Does the solution have anything to do with "targetsAndToolsNeedGrouping"?
Try opBoolean with BooleanOperationType.SUBTRACT_COMPLEMENT
The sets of parts will then go respectively into tools and targets.
IR for AS/NZS 1100
I've moved my Feature Studio out of the original document to clean things up and I'm ready for people to start using this thing!
https://cad.onshape.com/documents/7357473bee84cfbece0caa72/w/6b1397ebf6249eadf5cb37c5/e/685da06f47a08a112cd05cdf
An improvement wishlist that I may or may not get to would be:
- more pattern types
- better default values
- end conditions
- option for custom input body (instead of a cylinder)
- figure out something to make the center of the Fibonacci pattern not look so funny (even though it's right as far as i can tell)
I'm open to ideas.Here's an example of what the feature can do.
HWM-Water Ltd
HWM-Water Ltd