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, User Group Leader, csevp Posts: 109 PRO
edited June 2019 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? :)







Comments

  • ilya_baranilya_baran Onshape Employees, Developers, HDM Posts: 1,173
    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 \ VP, Architecture and FeatureScript \ Onshape Inc
  • NeilCookeNeilCooke Moderator, Onshape Employees Posts: 5,308
    edited June 2019
    You can also do this using Editing Logic if you want the field to change dynamically. See the Spur Gear for an example. 
    Senior Director, Technical Services, EMEAI
  • bill_schnoebelenbill_schnoebelen OS Professional, Developers, User Group Leader, csevp Posts: 109 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.