Graphics

 View Only
  • 1.  Help Using Visual Logic to Colorize Text

    Posted 09-03-2020 06:11

    Hello,

    Can anyone help me figure out how to colorize text using Visual Logic based on its actual data values?  I didn't see any threads that quite touched on this.

    Example:

    0-9 = green material
    10-19 = yellow material
    20+ = red material

    I was trying this for each range but getting inconsistent results with the resulting color coding.  What am I doing wrong?  How would you go about it?

     



  • 2.  RE: Help Using Visual Logic to Colorize Text

    Posted 09-03-2020 13:12

    Almost there!

    What's happening here is that as your value trips each GreaterThan/Eq To function block, the resulting bool value is added to your index. Then, you need to feed the materials into the respective index, finding those can be tricky. When you open the fonts pulldown in VL interface you get a lot of DefaultMatXXX, these are the names of the LAYERS within the fonts, not the font names themselves you assign in the Scene Font Panel. So for your fonts you'll need to hit "edit material" within the respective ones and find the name of the Layer within, I renamed them so they would be easier to find in the sea of DefaultMat options.

    The tree above will work for 1 object, for multiples you'd have to get to get several trees going that swap the "Value 1.Text" and "Value 1.Face". For a few numbers this may not be too bad, but if you have a lot of values within a scene that need this treatment I'd suggest switching to a scripting to achieve that instead.


    #XPression


  • 3.  RE: Help Using Visual Logic to Colorize Text

    Posted 09-03-2020 17:07

    Martin, many thanks!!  I've done all that but it's still not working 100% for me.  The colors don't output correctly and the only difference I see is that your input selector starts with 1 instead of 0 and you have different block values displaying such as 1 under the math and one of the logic boxes.  Mine all show 0.  


    #XPression


  • 4.  RE: Help Using Visual Logic to Colorize Text

    Posted 09-03-2020 17:17

    Oh yeah, you'll want to click on your input selector and and offset the index to 1. If maybe you had some different conditions where you want your color coding to start at 10 and everything below was a default color (say white or black) then you'd want to have it start at zero and add an additional default material.

    As far as the Add block displaying zero, if they are all showing zero and your text field is filled, then try hitting the continuous animation button on your layout mode (blue icon at the top of your viewport pictured below), if that isn't activated in layout mode, it won't update the functions. If that doesn't solve, send back your visual logic tree.


    #XPression


  • 5.  RE: Help Using Visual Logic to Colorize Text

    Posted 09-03-2020 18:00

    Thanks!  That did it.  


    #XPression


  • 6.  RE: Help Using Visual Logic to Colorize Text

    Posted 09-04-2020 13:26

    What's the best way to tackle data that's resulting in a mismatch by 1 material (in terms of the ordering) when output from an input selector?  I can't just offset the input selector because it's actually off by -1 and it's not every item either, which is why I'm scratching my head.  +1 using an offset prior to connecting the add block to the index does work for some items but not all d'oh lol.   

    I’ve played with offsets, subtract (instead of add), reverse ordering the materials when connecting them with the input selector, and not using the base connector on the add block (because in my instance it was the item value connected to the base in the add block that was actually resulting in correctly alining with the proper material when output from the input selector but others were off).

    I checked my work and from what I can tell the order of the logic connected to the add block matches the input selector's material order list.  I can't always use a range in my logic blocks so I'm using a combination of equal to or greater than/eq to achieve things (example: 500 = green material, 502-511 = green material, but 501 might = red material).  So if I connect two instances of the green material in a row within the input selector what I've noticed is if I offset, the result then skips over any multiple instances of the same material like that and moves to the next new material on the list.  Maybe I should duplicate my materials and name them x1 material, x2 material, etc. to force that to not happen and then try offset again?    


    #XPression


  • 7.  RE: Help Using Visual Logic to Colorize Text

    Posted 09-04-2020 13:47

    I'm not sure I follow you, the offset is there because the first condition 0-9 requires it to be true. For what it's worth, you can set your base value directly within the Greater Than/Eq to function block. In my example these values would be 0, 10, 25 respectively.

    If you have no need for a default value, you could delete the first 0-9 conditional and start your input selector on 0 (keeping all the materials are they are). But going back to my original VL tree, the written out version of it is as follows (using 27 as our example value):

    Is this text value greater than zero? True (1), is the text value also greater than 10? True (1), is the text value also greater than 25? True (1), add all of these conditions together which makes a total of 3. Feed that 3 into the index of an input selector, an index of 3 is set to the red material. Make the face of the object's material red.

    So if you change any offset anywhere or manipulate the resulting value of those bools added together, it's going to throw off what your input selector is trying to feed into your object.

     

     

     


    #XPression


  • 8.  RE: Help Using Visual Logic to Colorize Text

    Posted 09-04-2020 14:20

    Okay now I get it...I think I got it working.  What I did was remove one material and change the input selector to offset by 1.  I'll do some tests to make sure that'll work for all of my ranges.  Appreciate that explanation in your sample because that's what made the light bulb go off in my head.


    #XPression