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.

Feature Script Parameter Bounds driven by another Parameter

bill_schnoebelenbill_schnoebelen OS Professional, Developers Posts: 20 PRO
edited June 11 in General
I am trying to bound a parameter based on the input to another parameter. 

For the code below. I want to always make sure Y is less than or equal to X. In another case, I would want Y to be 1/3 X. Is this possible?

If not, is there a TextBox.Change event where I can test? :)


  • ilya_baranilya_baran Onshape Employees, Developers, HDM Posts: 944
    You can test in the feature body itself, something like:
    if (definition.y > definition.x)
        throw regenError("y must not be greater than x", ["y"]);
    (passing the parameter y in the second argument to regenError will make it highlight in red if it's out of focus)
    Ilya Baran \ Director, Architecture and FeatureScript \ Onshape Inc
  • NeilCookeNeilCooke Moderator, Onshape Employees Posts: 2,537
    edited June 11
    You can also do this using Editing Logic if you want the field to change dynamically. See the Spur Gear for an example. 
  • bill_schnoebelenbill_schnoebelen OS Professional, Developers Posts: 20 PRO
    Thanks guys. I think either of those will work. I am going to use the first one for now since it is simpler.
Sign In or Register to comment.