Using Float Expression to Control $Text001.text value

Using Float Expression to Control $Text001.text value

pierre
Contributor Contributor
1,396 Views
7 Replies
Message 1 of 8

Using Float Expression to Control $Text001.text value

pierre
Contributor
Contributor

Not sure what is happening here.

 

This works fine fromm the Script Listener.

 

I run this function

 

fn TimeFromSolarTime daylightSystem =
(
local solar_time = daylightSystem.controller.solar_time.controller.value
local hrs = int solar_time
local min = int ((solar_time-hrs)*60)
local sec = int ((solar_time-hrs-min/60.0)*3600 + 0.5)
#(hrs,min,sec)
)

 

$Text001.text = TimeFromSolarTime $Daylight01 as string

And the text updates to the value of #(hrs,min,sec)

 

As long as you have a daylight system and a piece of text this works from the listerner.

 

In track view I find the kerning property for this text001

and  assign a float expression

I put the same in for the expression box

$Text001.text = TimeFromSolarTime $Daylight01 as string

I get an error parsing ...

with a $

 

I've done this in the past with different functions like mph and it always seemed to work.

Any ideas would be much appreciated.

 

0 Likes
Accepted solutions (2)
1,397 Views
7 Replies
Replies (7)
Message 2 of 8

Steve_Curley
Mentor
Mentor
Accepted solution
Using the Kerning is correct, but using a function in a situation where it can only run once is pointless, and I'm not even sure if you can use functions in an expression controller.
So, use a Float Script, create 2 Variables:-
TheText > Assign Node > select the Text object
TheSolarTime > Assign Track > select the Solar Time track within the Daylight object
The Script itself would be something like this (which does work)
hrs = int(TheSolarTime)
min = int((TheSolarTime - hrs) * 60.0)
sec = int((TheSolarTime - hrs - min / 60.0) * 3600 + 0.5)

s = stringstream ""
format "%:%:%" (formattedPrint Hrs format:"02i") \
               (formattedPrint Min format:"02i") \
               (formattedPrint Sec format:"02i") to:s

TheText.text = s as string

0 -- DO NOT REMOVE! this is the result of the script which is the Kerning value

Max 2016 (SP1/EXT1)
Win7Pro x64 (SP1). i5-3570K @ 4.4GHz, 8Gb Ram, DX11.
nVidia GTX760 (2GB) (Driver 430.86).

Message 3 of 8

pierre
Contributor
Contributor

Steve,

I sure do appreciate the input.  I tried this over the weekend and could not figure out how to make it go.

Just to dumb.  If possible could you link a max file with this solution.

Thanks for your patience.  I might be close but it may as well be a million miles away when things don't work.

Regards

Pierre

0 Likes
Message 4 of 8

Steve_Curley
Mentor
Mentor
You need to animate the time (hours is probably easiest). Post your scene (Zipped!, attach it to a reply) and I'll have a look, if you can't get it to work.

Max 2016 (SP1/EXT1)
Win7Pro x64 (SP1). i5-3570K @ 4.4GHz, 8Gb Ram, DX11.
nVidia GTX760 (2GB) (Driver 430.86).

0 Likes
Message 5 of 8

pierre
Contributor
Contributor

Thanks for taking a look.

 

 Don't know the correct syntax to assign TheSolarTime among other things.

 

 

0 Likes
Message 6 of 8

Steve_Curley
Mentor
Mentor
Accepted solution

Top-Left corner of the Float Script dialog, type "TheSolarTime" (no quotes) into the entry box and click Create.
With it still highlighted in the list, click Assign Track. In the dialog which appears, navigate your way to the Solar Time track of the Daylight object within the Compass object, highlight it and click OK. See the image.
Similarly for "TheText", create the variable (type the name and click Create), this time click Assign Node and navigate the the Text object, highlight it and click OK.
Click Evaluate and it should work, though I had to switch to a Perspective view, select the Text object from the Select by Name dialog then Zoom into it before I could see it - it's not in line with the Camera.

 

Assigning a track in a Float Script


Max 2016 (SP1/EXT1)
Win7Pro x64 (SP1). i5-3570K @ 4.4GHz, 8Gb Ram, DX11.
nVidia GTX760 (2GB) (Driver 430.86).

Message 7 of 8

pierre
Contributor
Contributor
This is fantastic!
I've never used assign track and node before.
Thanks for your patience and teaching an old dog some new tricks.
0 Likes
Message 8 of 8

Steve_Curley
Mentor
Mentor
I assume it works now? 😉

The "Assign" buttons replace the old "DependsOn" functionality which has been deprecated for many versions of Max. They are much quicker in operation - important when scrubbing the timeline as that bit of script has to be evaluated on every frame before it can be displayed.

Max 2016 (SP1/EXT1)
Win7Pro x64 (SP1). i5-3570K @ 4.4GHz, 8Gb Ram, DX11.
nVidia GTX760 (2GB) (Driver 430.86).

0 Likes