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.

Why are units being handled in two different ways by identical feature dialogs?

Fletcher_ChapinFletcher_Chapin Member Posts: 3
I have a predicate with units, defined here, which doesn't add units to the variables, but expects the variables to already have units, as you can see in this screenshot:

I have another predicate with units defined here, and even though the code appears identical to me, it's handling the units differently, as you can see here:

What this means is that I sometimes have to strip the units before passing variables into the dialog (I've written an FS function for that) but I'm confused why the behavior is inconsistent, so that in each Parts Studio I may or may not have to strip the units.

Answers

  • alnisalnis Member, Developers Posts: 452 EDU
    I don't have any experience with featurescript, but what that looks like to me is that #outletHW is a variable of type length (so it has units) while #HLbod is a unitless variable (either integer or real). What does it look like if you type in plain old numbers? E.g. if you were to type 10 and press enter.
    Get in touch: contact@alnis.dev | My personal site: https://alnis.dev
    @alnis is my personal account. @alnis_ptc is my official PTC account.
  • Fletcher_ChapinFletcher_Chapin Member Posts: 3
    You're right that it is expecting a unitless variable, but it shouldn't be. The dialog box is supposed to accept a value with or without units and handle it accordingly. You can see below what happens if I try to use #HLbod with units.


    I realized the following behavior is what's causing this:

    1) the variable #HLbod was created as a unitless number, 0.3
    2) that variable was entered into the dialog box which desired units, so it now appears as (#HLbod) m in the dialog box
    3) the value of #HLbod was modified to include meters
    4) the dialog box doesn't check if the variable was modified since it was entered, so it continues to try to pass in the expression (#HLbod) m. HOWEVER, #HLbod was redefined from a unitless 0.3 to 0.3 meters, so the predicate throws an error, stating that 0.3 meter meter is not a valid length.

    Ideally, the dialog box would check the variable's units whenever it ran the feature, not just once upon variable entry.
Sign In or Register to comment.