Welcome to the Onshape forum! Ask questions and join in the discussions about everything Onshape.

First time visiting? Here are some places to start:
  1. Looking for a certain topic? Check out the categories filter or use Search (upper right).
  2. Need support? Ask a question to our Community Support category.
  3. Please submit support tickets for bugs but you can request improvements in the Product Feedback category.
  4. 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_heliotismalory_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:

  1. The Feature Studio notices show no errors; the function is recognized as "conforming" and the bounds are recognized as a "map" and a "range."
  2. The error value.min is ValueWithUnits suggests that the FS 355 runtime is incorrectly attempting to validate the unitless minimum value (3) against a physical length unit (likely millimeters or meters).
  3. I have attempted several workarounds, including:
    • Using isReal with RealBoundSpec.
    • Moving the map definition directly into the isInteger call (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").

Environment:

  • FeatureScript Version: 355
  • Standard Library: onshape/std/geometry.fs version 355.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?

Tagged:

Best Answer

  • NeilCookeNeilCooke Moderator, Onshape Employees Posts: 6,035 image
    Answer ✓

    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, EMEA

Answers

  • NeilCookeNeilCooke Moderator, Onshape Employees Posts: 6,035 image

    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.

    Senior Director, Technical Services, EMEA
  • jnewthjnewth Member, OS Professional Posts: 130 PRO

    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.

  • NeilCookeNeilCooke Moderator, Onshape Employees Posts: 6,035 image
    Answer ✓

    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, EMEA
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. Sign in or register to get started.