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.
shared predicate definition with slight differences
EvanReese
Member, Mentor Posts: 2,135 ✭✭✭✭✭
I'm trying to get between. In this case, I'm trying to write one predicate for my Cone and Prism features. The only difference between them is the definition.sides number for the prism. How can I write this only once, and hide that field on the Cone feature but show it on Prism? Link below to see what I'm trying to do.
https://cad.onshape.com/documents/a81f647d405a78c5b70bdbde/w/cb4099ea5a4f73db91ad5b5b/e/b82bd38a9390b4dd3155b161
https://cad.onshape.com/documents/a81f647d405a78c5b70bdbde/w/cb4099ea5a4f73db91ad5b5b/e/b82bd38a9390b4dd3155b161
Evan Reese
0
Best Answer
-
chadstoltzfus Member, Developers, csevp Posts: 142 PROIt looks like you went for sending an "isPrism" argument to the predicate, which should work. You could also set a key/value pair in the precondition of Prism feature and have the predicate do a check to see if that key is defined in the definition map.Applications Developer at Premier Custom Built
chadstoltzfus@premiercb.com0
Answers
chadstoltzfus@premiercb.com
Here's what I ended up doing which worked, but I'm guessing there's a cleaner way.
in both preconditions (Cone and Prism) I added this:
With the default set true in Prism and false in Cone. Then I made the "sides" field conditionally visible with
When I say key/value pair in the precondition I really mean another parameter. As you're probably aware, a feature definition is nothing more than a map, and maps consist consist of key/value pairs. Ex:
So in this specific use case the key/value pair being used is "isPrism"/true.
In my mind when dealing with predicates talking about a definition more like a map than a UI element makes sense because predicates are a more granular level of what the precondition (UI code block) of a custom feature entails.
chadstoltzfus@premiercb.com