Notifications
Clear all

[Closed] TextPlus animation not works as expected

Hi!

The goal is to animate textPlus objects so on every frame of animation to show different text.
This is the code that I use:

(
	tp1 = textPlus size:25 pos:[0,0,0]
	tp2 = textPlus size:25 pos:[0,50,0]
	
	textObjsArr = #(tp1, tp2)
	
	strArr = #(#("Monday", "Tuesday ", "Wednesday ", "Thursday", "Friday", "Saturday", "Sunday"), #("Jan", "Feb", "Mar", "Apr", "Maj", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"))
		
	animationRange = (interval 1 12)
	
	slidertime = 1
	for i = 1 to textObjsArr.count where isValidNode textObjsArr[i] do
	(
		t = textObjsArr[i]
		theCtrl = float_script()
		theCtrl.addNode "TheText" t
		theCtrl.addConstant "strArr" strArr[i] 
		theCtrl.SetExpression "if F != 0.0 then TheText.SetPlaintextString strArr[F]\n0"
		t.tracking.controller = theCtrl
	)	
)

But, when I run it and then I move the animation slider the text that both textPlus objects shows is not correct.
On frame 1 it shows Feb and Tuesday, nex time it may show Mar and Wednesday, etc.
Just play with the animation slider and you will see what I mean.

Is my code wrong?

26 Replies

Set the FPS to 1 (in Viewport – Time configuration) and check.

1 Reply
(@miauu)
Joined: 10 months ago

Posts: 0

Do you mean to set the FPS here:

The same problem exist when I set FPS to 1.

Yes, but that’s just quick way to normalize time, check for problems in expression…

You have to set time range after that again.

Best would be to debug it in controller window, I think you have probs with S variable.

Here is updated code:

(
	tp1 = textPlus size:25 pos:[0,0,0]
	tp2 = textPlus size:25 pos:[0,50,0]
	
	textObjsArr = #(tp1, tp2)
	
	strArr = #(#("Monday", "Tuesday ", "Wednesday ", "Thursday", "Friday", "Saturday", "Sunday"), #("Jan", "Feb", "Mar", "Apr", "Maj", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"))
		
	animationRange = (interval 1 12)
	
	slidertime = 1
	for i = 1 to textObjsArr.count where isValidNode textObjsArr[i] do
	(
		t = textObjsArr[i]
		theCtrl = float_script()
		theCtrl.addNode "TheText" t
		theCtrl.addConstant "strArr" strArr[i] 
		theCtrl.SetExpression "print F\n print strArr[F]\n if F != 0.0 then TheText.SetPlaintextString strArr[F]\n0"
		t.tracking.controller = theCtrl
	)	
)

In the maxscript listener it shows proper F and strArr[F] which means that the code reads the proper day and month, but the TextPlus objects shows wrong day and month.
No matter if I set FPS to 1 and then I set the time range again and after that I run the script – the problem exist.

Tried for a while without success, sorry.

Hi, Andres!

Thank you.
Yes, no mater what I do it not works. But if a regular Text object is used then everything works fine.

(
	tp1 = text pos:[0,0,0]
	tp2 = text pos:[0,50,0]
	
	textObjsArr = #(tp1, tp2)
	
	strArr = #(#("Monday", "Tuesday ", "Wednesday ", "Thursday", "Friday", "Saturday", "Sunday","Monday", "Tuesday ", "Wednesday ", "Thursday", "Friday"), #("Jan", "Feb", "Mar", "Apr", "Maj", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"))
		
	animationRange = (interval 1 12)
	
	slidertime = 1
	for i = 1 to textObjsArr.count where isValidNode textObjsArr[i] do
	(
		t = textObjsArr[i]
		theCtrl = float_script()
		theCtrl.addNode "TheText" t
		theCtrl.addConstant "strArr" strArr[i] 
		theCtrl.SetExpression "if F != 0.0 then TheText.text  = strArr[F]\n0"
		t.kerning.controller = theCtrl
	)	
)

It is time to find workaround.

upd not really working ;(

I am testing it on max2020 and it not works.

Here is a video that shows what happen on my PC.

https://drive.google.com/file/d/10alphEdBwlMNZXIHZ_kIdbJiQPlMyc7o/view?usp=sharing

You have “array index must be positive number” thingy.
That means integer also. I dont know why it’s not getting those values only from yours frames but I think that you’ll have to define it “precisely” – as a whole, positive numbers.
Try google that expectation, there are some results for Max.

My FPS thing can be quick’n’dirty help in some places, but not here, obviously.

delete objects

t = textplus dir:-y_axis isselected:on
s = t.tracking.controller = float_script()
s.addnode "self" t
s.addconstant "list" #("A:","B:","C:","D:","E:","F:") 
s.setexpression "text = formattedPrint (int T) format:\"06X\"; self.setPlaintextString (list[mod F 6 + 1] + text); 0"

all works for me (MAX 2018 and MAX 2020)

Page 1 / 3