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.
Choosing inputs based on Lookup tables
DSPuzzles
Member Posts: 17 EDU
Suppose I have a parameter definition.table based on the following lookup table:
"Color"
"Reds"
"Light Red"
"Dark Red"
"Blues"
"Light Blue"
"Dark Blue"
Is there a way of having definition.table determine whether or not a second parameter shows up in the feature UI, based on whether the user selected "Reds" or "Blues"? I can only seem to find a way of doing it for the very last item in the tree ("Light Red", "Dark Red", ""Light Blue", "Dark Blue").
Thank you very much!
"Color"
"Reds"
"Light Red"
"Dark Red"
"Blues"
"Light Blue"
"Dark Blue"
Is there a way of having definition.table determine whether or not a second parameter shows up in the feature UI, based on whether the user selected "Reds" or "Blues"? I can only seem to find a way of doing it for the very last item in the tree ("Light Red", "Dark Red", ""Light Blue", "Dark Blue").
Thank you very much!
Tagged:
0
Best Answer
-
kevin_o_toole_1
Onshape Employees, Developers, HDM Posts: 565
I think this is not possible right now. If you really need this functionality, you could take apart your lookup table and structure it as many nested "if" statements with their own dropdown menu, but this would remove the advantages (ease of creation, scalability, code reuse) that lookup tables gain you in the first place.
Possibly the best solution is just having the query always visible, perhaps with an error state set ( throw regenError("reason", ["queryParameterId"]) ) when one of the "Reds" is selected. This would indicate to the user that the feature needs the query filled out in this case, showing the "message" when they hover their mouse on the feature or the parameter.
5
Answers
I think so
Try something like this:
export const lookupTable = { "name" : "color", "displayName" : "Color", "entries" : { "Red" : color(1, 0, 0), "Blues" : { "name" : "darkness", "displayName" : "Darkness", "entries" : { "Light blue" : color(0.75, 0.75, 1), "Dark blue" : color(0, 0, 0.75), } }, } };IR for AS/NZS 1100
Possibly the best solution is just having the query always visible, perhaps with an error state set ( throw regenError("reason", ["queryParameterId"]) ) when one of the "Reds" is selected. This would indicate to the user that the feature needs the query filled out in this case, showing the "message" when they hover their mouse on the feature or the parameter.
This topic is actually really important to me. I've been trying to find an efficient way to implement Kevin's suggestion. The UI of my custom feature is a high priority and I want to get more granularity with visibility conditions. The lookup tables will likely not change too much over time so I am okay with the loss of scalability this solution will incur. So we want to get to an end result like this:
export const lookupTable = {"name" : "color", "displayName" : "Color", "entries" : { "Red" : {"name" : "darkness", //Red option "displayName" : "Darkness", "entries" : { "Light red" : color(0.75, 0.75, 1),//typical followup decision for colors "Dark red" : color(0, 0, 0.75), }}, "Blues" : { //similar to red }, "Greens":{//also similar to red } "Striped" : { //different from other colors "name" : "Stripe_Thickness", "displayName" : "Stripe Thickness", "entries" : { "thin" : 1.546, "thick" : {"name" : "Thick", "displayName" : "Even more", "entries" : { "super" : "foo", "aewrqewr" : "foofoo" ... <br>We have many color options, some of which are similar and require similar followup choices, while other colors like "striped" take you down a different decision tree, etc. I'm sure we can leverage the similarity of these choices and the Map methods to generate this lookup table, but I am unsure on the specifics and also how to access this lookup table if it is in a separate FS module from where it is called (is this the biggest problem?.) I basically want to create a few arrays that contain different configuration options, and loop through them to nest the lookup table:toString(colors[i]):{"name":"ColorOptions", "displayName":"Visual Options","entries":{}}}; //Branch colors vs striped if(colors[i]!=="Striped"){ //loop over color options if colored, then merge maps with currently empty "entries" map within current color for(var j=0;j<size(ColorOptions);j+=1){ ((Entries.(keys(Entries)[0]))=mergeMaps(Entries[i].keys(Entries[0]),{toString(ColorOptions[j][0]):[i,j]})Any thoughts on this? I'm sure people have already done this, but I couldn't find a thread for it. I could use suggestions with the overall structure/map building. As far as using it, as a last resort I may have to run a script like this to print out the look up table and just copy paste into a FS file each time I want to update...... //Each endpoint ^^^^^ //is just an array or encoded string or something else{ for(var j=0;j<size(StripeOptions);j+=1){ //loop over stripe options
}
export const lookupTable = {"name" : "color", "displayName" : "Color", "entries":Entries}//High level choice const colors=["red","blue","green","striped"] //Conditional followup choices const ColorOptions=[["Light","light"],["Dark","dark"],["VeryDark","verydark"] const StripeOptions=[["Thick","thick"],[["Thin","thin"]] var Entries={}; //first loop creates empty color entries of the form: for(var i=0;i<size(colors);i+=1){ //here Entries=mergeMaps(Entries,{IR for AS/NZS 1100
PhD, Mechanical Engineering, Stanford University