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.

Options

How is variable type assigned to variables?

Evan_ReeseEvan_Reese Member Posts: 2,064 PRO
If I set a length variable with the Variable feature and look at it in the variable table, it show's the "variable type" as "length", but if I set the same value with setVariable() in FS, it shows as "Unspecified". How do I make it show "length" etc?
Evan Reese / Principal and Industrial Designer with Ovyl
Website: ovyl.io

Best Answers

  • Options
    _anton_anton Member, Onshape Employees Posts: 272
    edited September 2022 Answer ✓
    The standard variable feature has some special handling because we know how it's structured and what value field to show for each type (if you look at the source code, you'll see that length/angle/etc. have different fields in the precondition). With custom features, all bets are off about feature structure, so we just show the value with no type instead of trying to be too clever.
  • Options
    _anton_anton Member, Onshape Employees Posts: 272
    Answer ✓
    Depends on what you're trying to do, but yeah, I wouldn't anticipate any more interactivity with the table. Normally, custom feature rows are entirely read-only; the only special allowance we give is a name field with UIHint.VARIABLE_NAME, in which case you can rename. But the type is hardwired to only work with the standard feature.

Answers

  • Options
    _anton_anton Member, Onshape Employees Posts: 272
    edited September 2022 Answer ✓
    The standard variable feature has some special handling because we know how it's structured and what value field to show for each type (if you look at the source code, you'll see that length/angle/etc. have different fields in the precondition). With custom features, all bets are off about feature structure, so we just show the value with no type instead of trying to be too clever.
  • Options
    Evan_ReeseEvan_Reese Member Posts: 2,064 PRO
    _anton said:
    The standard variable feature has some special handling because we know how it's structured and what value field to show for each type (if you look at the source code, you'll see that length/angle/etc. have different fields in the precondition). With custom features, all bets are off about feature structure, so we just show the value with no type instead of trying to be too clever.
    Thanks, Anton. So should I be taking from this that it's not worth trying to do it in a custom feature?
    Evan Reese / Principal and Industrial Designer with Ovyl
    Website: ovyl.io
  • Options
    _anton_anton Member, Onshape Employees Posts: 272
    Answer ✓
    Depends on what you're trying to do, but yeah, I wouldn't anticipate any more interactivity with the table. Normally, custom feature rows are entirely read-only; the only special allowance we give is a name field with UIHint.VARIABLE_NAME, in which case you can rename. But the type is hardwired to only work with the standard feature.
Sign In or Register to comment.