### Author Topic: A sequence of IF statements ("Comparison" nodes, technically)  (Read 1874 times)

#### justaviking

This is a follow-on to my question about using a single value to control several nodes:
https://forum.allegorithmic.com/index.php/topic,22921.0.html
but it seemed different enough to justify being a new thread.

MY GOAL:

I want to use a slider to select from a series of pre-defined text strings.  Simply using A, B, C, and D for testing.

It started easy enough.
- Created an INTEGER "input" parameter
- Used a SWITCH node to toggle between two letters, such as A and B
- Changed the True/False button on the Switch node to use a FUNCTION that resulted in a BOOLEAN output
- That seemed to work great

Here is my problem:
- I have a string of Switch nodes
- All are set up the same way, using a function that references the input slider
- Each function is compared against a different integer value (1, 2, 3, or 4)
- But I don't get consistent results... two nodes will switch at the same time, and the one that should switch, might not

Example:
- In the first picture below, with Input=2, the top row should be...
--- Blank  (this is my starting state)
--- Blank  (because the slider value is not "1")
--- B        (Because slider value = 2)
--- B        (Because slider value is not "3")
--- B        (Because slider value is not "4")

Analysis:
- I don't know.
- It's like the nodes randomly decide to share the same function values with each other
- But if I select a Switch node and "Edit" the function, the "Compare" is always using the correct number (1, 2, 3, or 4)

- Any ideas?

Project file attached:
- In case it helps
- Ignore the inputs is_a, is_b, is_c, is_d...  I only started playing with them after I encountered this problem, but then decided they weren't going to be useful.

The bottom row of letter are the "input" text strings.
The top row should only contain blanks, followed by the desired letter (Example:  Blank-Blank-B-B-B)

This is the Function for the letter "B"...
Last Edit: March 17, 2018, 07:11:46 am
Hobbyist
----------
Common "Help" suggestions:
- LOG FILE tips - https://forum.allegorithmic.com/index.php/topic,22451.0.html
- LICENSING issues https://www.allegorithmic.com/contact
- ATTACH files and pictures to posts: https://forum.allegorithmic.com/index.php/topic,23670.0.html

#### justaviking

I did some experimenting... still no joy...

All I can think of is it's because all those nodes share the same "Parameter name" - in this case, "Switch."  It's like Designer shares that parameter value between nodes in some way.  When you do this all manually, using the True/False button, of course each node retains its individual setting as it should.

I tried a similar test, controlling the Font Color on the Text node.  (See picture, below.)  I get the same "random" or result where you never really know which of several Text nodes will actually get the color you wanted.  The control works fine with a SINGLE NODE, but when I have several nodes using similar functions (varying only in the Constant), the results are unreliable.

Or.....   Is it because the "Output" node appears the same in every function?

Is there anyway to give the Node "Parameters" a unique name (switch_a, switch_b, switch_c)?  Or the output node in the function?  Something like that?

I'm stuck.

This function correctly toggles between white/black font colors based on my integer slider... as long as I only control one text node with it.  If I try to control three nodes, with each function properly set to compare against 1, 2, or 3, the nodes do not behave properly.
Last Edit: March 17, 2018, 03:23:23 pm
Hobbyist
----------
Common "Help" suggestions:
- LOG FILE tips - https://forum.allegorithmic.com/index.php/topic,22451.0.html
- LICENSING issues https://www.allegorithmic.com/contact
- ATTACH files and pictures to posts: https://forum.allegorithmic.com/index.php/topic,23670.0.html

#### Esger van der Post

Hey viking!

It looks like you did everything right except how you plugged in your switches
This way around, it should work great

Just in case you haven't, turn on this option

So you can see which input is the 'true' and which is the 'false' input.

By the way, you can turn your integer1 into a dropdown list so you can title the input, instead of just havin a slider going from 1 to 4 or whatever.

As you can see, it still interprets it as numbers from 1 to 4, but visually adds a title 'A, B, C and D'

#### justaviking

THANK YOU!

Face-palm.  There was something in the back of my mind...  why does the numbering seem to be off by one (to the limited extent it did seem to work...  yeah, that was it.

Somehow I sort of hoped you (Eggfruit) might show up.  I just needed that second set of eyes.

Regarding the drop-down list, I wondered about that, but was focused on getting it to work first.

Why so convoluted?  I'm going to an application (iClone) that does not understand the "Text input" for the Text node.  In Painter you can simply type in whatever you want, but not in iClone.  (Enhancement request to be submitted to them later today.)  What I'm making is a towel with an optional monogram, so A-Z, His, and Hers.  I'l post pictures after I touch up the terry cloth material a bit more.

Thanks again.
Hobbyist
----------
Common "Help" suggestions:
- LOG FILE tips - https://forum.allegorithmic.com/index.php/topic,22451.0.html
- LICENSING issues https://www.allegorithmic.com/contact
- ATTACH files and pictures to posts: https://forum.allegorithmic.com/index.php/topic,23670.0.html

#### pimhendriks

You could also go into the Multiswitch, add a couple extra inputs and blends, export to your custom node and connect all text nodes. Not sure what is faster, but here's what I did. A little less convoluted.

#### Esger van der Post

I'm glad it helped. Pim makes a very good point by the way.
I was just focused on the technical part of your question, but you could just use the multiswitch node as it is, and just plug in every option you want available. It only goes up to 20 or so, so you'd still need to do a bit of this same kind of "programming" to hook 2 or 3 of them up to get all the options you want.

#### justaviking

Thanks, Pim.  I sort of (very briefly) looked for some multi-switch node.  I was pretty sure there was one that might work, but the 20-second inspection wasn't very promising, so I went back to what I was doing.  I'll open your examples and check that out.

It is funny how you can get so focused on one aspect that you sort of keep doing the same thing over and over again.  Just like how a magician uses misdirection to divert your attention away from where the real magic is happening.  I was so certain it should work, and that I was probably doing something dumb.  Correct on both counts.

My other next step is to see how iClone handles the drop-down list.  (I'm pretty confident the Integer slider will work, so that's what I'll test first.)

Thanks again to both of you.

Yay!  The drop-down list works fine in iClone.  That's a lot better than a numeric slider.  Very applicable to any text, such as "Open/Closed" and "On/Off" or whatever.

The "Grayscale Switch" works great.  Too bad I wanted 28 inputs, but the 26-input limit is reasonable.

LOL - This is why I should not do Substance Designer after my bedtime.  When I looked at Grayscale Switch, I only saw two inputs.  So then I looked at some of the other switches.  Too bad I didn't adjust "Input number."  I'm not sure what I thought it was, but now I quickly discovered it means, "How many inputs do you want?"

Anyway... I'm in pretty good shape now.  I'll probably use my switch-switch-switch-switch approach, and load it up with A-Z,His,Hers.
Last Edit: March 19, 2018, 03:55:15 am
Hobbyist
----------
Common "Help" suggestions:
- LOG FILE tips - https://forum.allegorithmic.com/index.php/topic,22451.0.html
- LICENSING issues https://www.allegorithmic.com/contact
- ATTACH files and pictures to posts: https://forum.allegorithmic.com/index.php/topic,23670.0.html