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.
Feature interface programming
DSPuzzles
Member Posts: 17 EDU
I am writing a feature that has a significantly complex interface. This means that the precondition in the feature is a mess. Is there a way to simplify the precondition? Such as loading annotations from another FeatureScript file, for example.
Tagged:
0
Comments
-
Factoring portions of the precondition into predicates is the best I can suggest -- see for instance how booleanStepScopePredicate (defined in boolean.fs) is used in std.Ilya Baran \ VP, Architecture and FeatureScript \ Onshape Inc0
-
This is precisely what I need. Thank you very much!0
-
Actually, it's not fixing the problem as I thought it would. Is there a way I can reuse a predicate inside a precondition?
Because I have an interface that uses a query only in certain places, and I'm using an if statement to decide whether to use it or not. The thing is, the condition becomes a long unreadable mess because it's quite complex. Predicates would solve this if it weren't for the fact that they can only be used once.
0 -
I see -- you want to avoid copy/pasting the if condition. Unfortunately, there's no current way to do that...Ilya Baran \ VP, Architecture and FeatureScript \ Onshape Inc0
-
The issue isn't copy-pasting. It's that my if statements look like this: (taken from the actual feature)if ((definition.family == familyEnum.CURVED && (definition.curvedSolid == curvedEnum.CYLINDER || definition.curvedSolid == curvedEnum.CONE || definition.curvedSolid == curvedEnum.BICONE)) || (definition.family == familyEnum.POLYGONAL && (definition.polygonalSolid == polygonalEnum.PRISM || ((definition.polygonalSolid == polygonalEnum.PYRAMID || definition.polygonalSolid == polygonalEnum.BIPYRAMID) && definition.heightTypePYR == pyramidHeightEnum.HEIGHT)))){// Heightannotation { "Name" : "Height" }isLength(definition.height, LENGTH_BOUNDS);0

