I have the need to set a variable based on the state of another variable I'm trying to write it as cleanly as possible but not having much luck. I have a set of data with corresponding values that overlap and would like to take advantage of the ||(or) statement to clean up the expression but it's not working as expected. Below is the expression I've written which only ever returns "4" even when DIA. is clearly set to one of the other variables such as 0:0.25 or 0:0.375 etc.
DIA == [0' 0.2500"] || DIA == [0' 0.3125"] || DIA == [0' 1.1250"] || DIA == [0' 1.3750"] ? 4.5 : DIA == [0' 0.3750"] || DIA == [0' 0.5000"] ? 6 : DIA == [0' 0.4375"] || DIA == [0' 0.7500"] || DIA == [0' 0.8750"] || DIA == [0' 1.0000"] || DIA == [0' 1.2500"] || DIA == [0' 1.5000"] ? 5 : DIA == [0' 0.6250"] ? 5.5 : 4
Anybody know what I'm doing wrong?
Hi Grant,
I've tried to reproduce your issue and failed. Attached is a .dgn in which I've replicated your working units settings (to the extent I can divine them from your expression) and your expression. As I change the value of my DIA variable, the value of my Calc variable updates appropriately. Might be useful to download + test this file to see if it works correctly for you.
TernaryExpressions.dgn
If so, perhaps there's some difference with your working units settings. I will be glad to take a look at your file if you can provide it.
Regards,
Paul
Paul,
HexBolt.cel is attached below, the model needed is GRD8-2FW-1NUT the variable name is Max-25. Working units are ft:in.
HexBolt.cel
Thank you very much for the info, Grant. You mentioned importing csv files, are those csv files exported from specific models? While looking into the other models, the result as below:
1. The variable Max-25 works well in Model GRD5-1FW-1NUT with expression as "DIA == [0' 0.5000"] ? 3 : DIA == [0' 0.6250"] ? 4 : DIA == [0' 0.7500"] ? 5 : DIA == [0' 0.8750"] ? 6 : DIA == [0' 1.0000"] ? 6.5 : 5".
2. The variable Max-25 does not work in Model GRD5-2FW-1NUT with expression as "DIA == [0' 0.2500"] || DIA == [0' 0.3125"] || DIA == [0' 1.1250"] || DIA == [0' 1.3750"] ? 4.5 : DIA == [0' 0.3750"] || DIA == [0' 0.5000"] ? 6 : DIA == [0' 0.4375"] || DIA == [0' 0.7500"] || DIA == [0' 0.8750"] || DIA == [0' 1.0000"] || DIA == [0' 1.2500"] || DIA == [0' 1.5000"] ? 5 : DIA == [0' 0.6250"] ? 5.5 : 4".
3. It does not work in both GRD8-1FW-1NUT and GRD8-2FW-1NUT models.
Grace
Grace,
I used one of the Bentley generated (exported) .csv files to quickly and efficiently produce my own variable data sets in excel. Attached is an example of one such csv file the values in the variable list are all in pure ft because our normal working units are ft-In. This was only used to bring in the raw variable data needed to create the variations, any equations such as the one that started this thread were created inside MS.
Grd8+Washer+Nut.csv
Thanks for the csv file, Grant. it's helpful!
Looks like it's related to accuracy. In your file, 0.041667 is the value for variation 1/2-13 GRD8-HB and it's true that 0.5 displays as the value after importing csv file into model with ft-in as working unit. But after exporting csv file and check values, you'll find 0:0.50000400 displays as the value. Same issue with 1/4-20 GRD8-HB variation. To verify this, open attached dgn file, exported csv file then check values.(You'll find the variations added in MicroStation work well), exported csv file is attached too.
Test expression.dgnExported from MicroStation.csv
Defect 344028 is filed for tracking. Regards, Grace