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.
Trying to add units and bounds for velocity... am I missing something?
darren_13
Member, Developers Posts: 119 PRO
So I have this code:
This is based on the std featurescript, but I get all sorts of errors such as:
-Expected parameter id to be defined as a field on value
-Unexpected operator (EQUAL_TO) in feature precondition
-No matching predicate declaration for verifyBounds (I copied and pasted this in to be sure)
I don't know what is different between the std and what I tried but I seem to have messed something up
https://cad.onshape.com/documents/95877be3b17f49277e87a2c3/w/b503830fd20472014beb1221/e/034312f7fdec452704158115
folder Twist Calculator, feature scripts; Twist Calculator, Units
Thanks,
Darren
export type VelocityBoundSpec typecheck canBeVelocityBoundSpec; export predicate canBeVelocityBoundSpec(value) { canBeBoundSpec(value); @size(value) == 1; for (var entry in value) isVelocity(entry.key); } /** * True for any value with velocity units. */ export predicate isVelocity(value) { value is ValueWithUnits; value.unit == LENGTH_UNITS/TIME_UNITS; } export predicate isVelocity(value, boundSpec is VelocityBoundSpec) { isVelocity(value); verifyBounds(value, boundSpec); } export const VELOCITY_BOUNDS = { (meter/second) : [0, 100, 299792458] } as VelocityBoundSpec;
-Expected parameter id to be defined as a field on value
-Unexpected operator (EQUAL_TO) in feature precondition
-No matching predicate declaration for verifyBounds (I copied and pasted this in to be sure)
I don't know what is different between the std and what I tried but I seem to have messed something up
https://cad.onshape.com/documents/95877be3b17f49277e87a2c3/w/b503830fd20472014beb1221/e/034312f7fdec452704158115
folder Twist Calculator, feature scripts; Twist Calculator, Units
Thanks,
Darren
Tagged:
0
Comments
Many thanks,
Darren