Welcome to the Onshape forum! Ask questions and join in the discussions about everything Onshape.
First time visiting? Here are some places to start:- Looking for a certain topic? Check out the categories filter or use Search (upper right).
- Need support? Ask a question to our Community Support category.
- Please submit support tickets for bugs but you can request improvements in the Product Feedback category.
- 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
papawo
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.
I have a #Variable array that I would like to select using UI booleans.
Tagged:
0
Comments
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.
It looks like you have three choices:
- 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".
- 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)
- 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!