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.

Featurescript to select the variable

papawopapawo Member, Developers Posts: 206 PRO
Is it possible to use featurescript to select the #variable array?
I have a #Variable array that I would like to select using UI booleans.

Comments

  • kevin_o_toole_1kevin_o_toole_1 Onshape Employees, Developers, HDM Posts: 442
    I'm not quite clear on what you're asking for. What do you mean by "a #variable array"? What's the goal of this feature? Does an Array parameter give the UI you're looking for?


  • papawopapawo Member, Developers Posts: 206 PRO

    this is my #variable
    when I put 3 in the #Option , it will choose 60in for the #Width

    Now what Im trying to do is create a custom feature that has a boolean selection of width.
    and when I select a 20in width from the boolean , it will trigger  #Option1
    I want to do a featurescript that will make use of setting variable I already have.
  • kevin_o_toole_1kevin_o_toole_1 Onshape Employees, Developers, HDM Posts: 442
    edited September 2017
    Okay, I think I see now.

    It looks like you have three choices:
    1. Create a length parameter allowing any value. If the user wants a specific value in their list, they can set that value to something referring to the Part Studio variables. e.g. "[20 in, 30 in, 60 in, 80 in][#Option]" or "#Width".
    2. Create an enum parameter with hard-coded values, (e.g. "20 in", "40 in"....). If you need a different set of values, you need a different feature (or some conditional visibility to switch between multiple dropdowns)
    3. Create an enum parameter with "Option 1", "Option 2", etc. and, inside the feature, use getVariable to extract the "Width" variable and extract the relevant item in the array.
    Generally speaking I'd encourage #1 or (more rarely) #2. If you do #3, the specific #Width parameter needs specific formatting (an array of precisely 5 values with length units) and a specific name, otherwise the feature fails. The user doesn't get good visibility into why it failed ("bad" variable), and, if it succeeds, they don't get feedback about what value "Option 1" referred to.

    Let me know if you have more questions!
Sign In or Register to comment.