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
Evan_Reese Member Posts: 1,771 PRO
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.
Evan Reese / Principal and Industrial Designer with Ovyl
chadstoltzfus Member, Developers Posts: 106 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.Software Engineer at Premier Custom Built
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.