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.
FS 355 Bug: isInteger with (unitless) bounds throwing ValueWithUnits error in Part Studio
malory_heliotis
Member Posts: 2 ✭
Description
Issue:
I am developing a custom Sprocket Tool using FeatureScript 355. I am encountering a persistent runtime error in the Part Studio that prevents the feature from regenerating, despite the code passing the Feature Studio's static analysis.
Error Message in Part Studio:
Precondition of defineBounds failed (canBeBoundSpec(boundSpec))onshape/std/valueBounds.fs:388:9 (value.min is ValueWithUnits)
The Code:The error is triggered by the following unitless parameter definition:
export const MY_Teeth_Bounds = { (unitless) : [3, 18, 500] } as IntegerBoundSpec;
annotation { "Name" : "Number of Teeth" }
isInteger(definition.numTeeth, MY_Teeth_Bounds);
Observations:
- The Feature Studio notices show no errors; the function is recognized as "conforming" and the bounds are recognized as a "map" and a "range."
- The error
value.min is ValueWithUnitssuggests that the FS 355 runtime is incorrectly attempting to validate theunitlessminimum value (3) against a physical length unit (likely millimeters or meters). - I have attempted several workarounds, including:
- Using
isRealwithRealBoundSpec. - Moving the map definition directly into the
isIntegercall (late-binding). - Using raw arrays
[3, 18, 500](which clears the Part Studio error but causes the Feature Studio to mark the function as "Nonconforming").
- Using
Environment:
- FeatureScript Version: 355
- Standard Library:
onshape/std/geometry.fsversion355.0
Is this a known issue with the legacy valueBounds.fs in version 355, and is there a recommended way to define unitless integer ranges in this version that satisfies both the static analyzer and the Part Studio runtime?
Best Answer
-
NeilCooke
Moderator, Onshape Employees Posts: 6,035
Yes, so if 355 is your thing, it should be like this:
const TEETH_BOUNDS = {
"min" : 4,
"max" : 250,
(unitless) : [4, 25, 250]
} as IntegerBoundSpec;Senior Director, Technical Services, EMEA1
Answers
Any particular reason you are using a version of the standard library from May 16th 2016? Try it with the latest (2945) and report back.
Your MY_teeth_bounds or whatever is missing min and max fields. Using the onshape-std-library-mirror I was able to easily look at that legacy version and see:
/** Typecheck for IntegerBoundSpec */export predicate canBeIntegerBoundSpec(value){ canBeBoundSpec(value); isInteger(value.min);isInteger(value.max);@size(value) == 3;value[unitless] is array;}so it's choking on the predicate (if i had to guess). Later versions don't have that min and max value.
Yes, so if 355 is your thing, it should be like this:
const TEETH_BOUNDS = {"min" : 4,
"max" : 250,
(unitless) : [4, 25, 250]
} as IntegerBoundSpec;