View Full Version : Xpresso and Spline Text

 cbowyer11 November 2005, 10:41 PMI built a bar chart the other day and placed a texture with the Spline effect on the top of each bar and then used Xpresso to update the Spline Text with the Y scale value. It all worked pretty well the text updated as the bar grew taller but I had a deadline at the end of the day and didn't have time to really explore xPresso to see what else was possible... Specifically I wanted to find out two things. 1) How to round the decimal value to 1 place. It seemed to have 3 places or none. 2) Concactinate a string onto the end of the value such as "km/h" or "bats" or whatever. I revisited the file for a few minutes today but didn't get any answers. Does anyone know if either of these is possible? with xPresso? warmest regards Cameron Bowyer
base80
11 November 2005, 01:06 AM
1. if you put the thing on integer it will give whole values instead of a value with a comma.
one decimal is another story altogether.

2. you can use maths add to add the km/h. But you must set the math node to string mode in order to work. you can add as many things as you like

cbowyer
11 November 2005, 02:14 AM
Thanks base80!

1. if you put the thing on integer it will give whole values instead of a value with a comma. one decimal is another story altogether.

Maybe I can turn it into a string and hack off the last two digits somehow. It doesn't really have to round, it just needs to be smaller than 3 decimal places.

2. you can use maths add to add the km/h. But you must set the math node to string mode in order to work. you can add as many things as you like

I'll play around with the add function tomorrow. Thanks again!

warmest regards
Cameron Bowyer

Darter
11 November 2005, 12:22 PM
Here’s an expression for rounding decimal values.

The expression works for values between -32,768 and 32,767, which is the range for the C++ short int variable type.

User Data are on the XPresso tag, where the number of decimal places can be set. The Output value is for demonstration purposes and can be removed, along with the node connected to the XGroup output.

The expression seems to work reliably but if there are any problems, feedback would be appreciated.

base80
11 November 2005, 01:26 PM
very cool darter, but could you make the rounding as an input port so i can save the node in the x-pool?

and the limitation of -32k to +32k is not very useful for many things, but ill work around it.

Darter
11 November 2005, 01:46 PM
Sure, here's a modified version of the file.

cbowyer
11 November 2005, 06:26 PM
Thanks Darter!

Darter
11 November 2005, 02:08 PM
I've reworked the expression so that it works for numbers outside of the -32,768 to 32,767 range.