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.

How is variable type assigned to variables?

EvanReeseEvanReese Member, Mentor Posts: 2,135 ✭✭✭✭✭
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

Best Answers

  • _anton_anton Member, Onshape Employees Posts: 410
    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.
  • _anton_anton Member, Onshape Employees Posts: 410
    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

  • _anton_anton Member, Onshape Employees Posts: 410
    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.
  • EvanReeseEvanReese Member, Mentor Posts: 2,135 ✭✭✭✭✭
    _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
  • _anton_anton Member, Onshape Employees Posts: 410
    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.