If Variable entered by machine operator is incorrect

I have 4 different “sizes” im looking for. eg. 8, 10, 15, 20. My script then runs with various if commands based on this size inputted by the operator. I cant seem to use the if command appropriately for if none of the sizes were chosen. Eg. operator wrote 120…
I thought- if “Variable” = 8,10,15,20 = false - it would work but no such luck.

I am working in polyscope but if someone has a solution in script thats okay.

I put two different ways since I was not entirely sure how you were doing it but the first option shows it as if 8, 10, 15, or 20 will run a single program if any are selected otherwise it does something else. Option 2 shows a separate program for each selection and again with a separate operation if none are entered. Inside the IF program node you can add ElseIf nodes and an Else node which is what I believe is what you are looking for.

Thank you that is exactly what i was looking for.

Now im struggling to find a script or node to restart the program. I can’t use the loop node because i only want to restart the program if “else” is followed which doesn’t seem to have a “loop when expression is “false”” command only true… but in my case it is false.

Are you only trying to restart when it falls into the Else category? and are you doing anything if it goes to the Else?

If you only want it to restart in the else case, you can put Halt nodes in the if/elseif options and leave the “Program Loops Forever” checkbox set so that the program will halt if it ran a part but return to the beginning otherwise.

Yes that worked thank you.

Im having trouble with the if command though, your suggestion of using else and ifelse worked well. I realised i can simplify it by putting -

Variable ≠ 8
Halt

However as soon as I put multiple variable figures in, the program just halts every time. eg -

Variable ≠ 8 or 10
Halt
^This doesn’t work for some reason

If you look at the example I provided before, you have to separate each check because it is checking whether variable != 8 or 10, which means its checking (Variable != 8) or (10) which will be true for 10. You will have to put (Variable != 8) or (Variable != 10) or …etc.

1 Like

Thank you that worked!

1 Like